Professional JavaScript for Web Developers, third edition of Nicholas K. Zakas (Wrox, 2012, pp. 210-215 describes "Inheritance of a parasitic combination" using the following function:
function inheritPrototype(subType, superType) { var prototype = object(superType.prototype); prototype.constructor = subType; subType.prototype = prototype; }
I have yet to figure out what the subType assignment for prototype.constructor does or should do. If I am missing something, the output I get using the example code is the same:
Without an extension object (prototype.constructor = subType;) in inheritPrototype: http://jsfiddle.net/Q22DN/
With the "add-on object" (prototype.constructor = subType;) in inheritPrototype http://jsfiddle.net/eAYN8/
Could this be a whole series of aimless code? Thanks for your explanation!
source share