Usage 1:
Bytes --------------------------------------------------------------------------------------------------------------
<SCRIPT>
// This is a constructor used to initialize the newly created "range object"
// Note that no object is created and an object is returned, only Initialization
Statement 1:
Function a (x ){
This. f = X;
}
Statement 2:
VaR A = function (){};
// All range objects are inherited from this object
// Note that the attribute name must be prototype.
A. Prototype = {
Add: function (y ){
Return number (this. f) + number (y );
}
};
// New A () creates a range object
X = new A (10). Add (8 );
?
Console. Log (x); // output: 18
</SCRIPT>
?
Usage 2:
Bytes --------------------------------------------------------------------------------------------------------------
<SCRIPT>
VaR A = function (x) {This. x = x ;};
A. Prototype = {
Add: function (y ){
Return this. x = This. x + number (y );
}
};
?
A. Prototype. Includes = function (){
???? Return this. x * 2;
}
?
_ Q = new;
_ Q. x = 50;
Console. Log (_ q. Events des ());
?
</SCRIPT>