Prototype Chain - RussellAbraham/js GitHub Wiki
Objects
Constructors
Prototypes
Enumerability
String Method
Returns
function Ctor(value){
this.preinitialize.apply(this,arguments);
this.value = value;
this.initialize.apply(this,arguments);
};
Ctor.prototype = {
preinitialize : function(){},
initialize : function(){}
};
Ctor.prototype.toString = function(){
return ''.concat(this.value,'');
};
Ctor.prototype.valueOf = function(){
return this;
};
function Node(value){
Ctor.call(this, value);
this.next = null;
this.prev = null;
}
Node.prototype = Object.create(Ctor.prototype,{
constructor: {
configurable : true,
enumerable: true,
value:Node,
writable:true
}
});
Extensions use instances of the Node constructor to populate data and attach static methods for that data. By setting constructor properties for new objects and their scalar, javascript can emulate high and low level modes of operation by using slightly more memory for each new object and the scalar.
Setting constructor properties to false can help performance once abstraction is in place.