First, we create a Parenizor class that has the get and set methods of member value, and a ToString method that wraps value in parentheses.
function Parenizor (value) {
This.setvalue (value);
}
Parenizor.method (' SetValue ', function (value) {
This.value = value;
return this;
});
Parenizor.method (' GetValue ', function () {
return this.value;
});
Parenizor.method (' ToString ', function () {
Return ' (' + this.getvalue () + ') ';
});
Implementation code
function Zparenizor (value) {
This.setvalue (value);
}
Zparenizor.inherits (Parenizor);
Zparenizor.method ("e;tostring" E;, function () {
if (This.getvalue ()) {
Return This.uber (' ToString ');
}
return " -0-";
});
Class inheritance is a kind of "is ..." relationship, and parasitic inheritance is a about "the original is ... And now is the relationship of .... Constructors play a large number of roles in the construction of objects. Note that the Uber (instead of the Super keyword) is still valid for the privileged method.
Class extension
The dynamic nature of the web effects allows us to add or replace methods for an existing class. We can call the method at any time. We can extend a class at any time. Inheritance is not the way. So we call this a "class extension" to avoid the extends── of Java, but not the same thing--confusing.