Professional JavaScript for Web Developers, Third Edition by Nicholas C. Zakas (Wrox, 2012, p.210-215 describes "Parasitic Combination Inheritance" 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 assignment of subType to the prototype.constructor does or is supposed to do. Unless I am missing something, the output I get using the example code is the same:
Without "augment object" (prototype.constructor = subType;) in inheritPrototype: http://jsfiddle.net/Q22DN/
With "augment object" (prototype.constructor = subType;) in inheritPrototype http://jsfiddle.net/eAYN8/
Can this really be a line of purposeless code? Thank you for your explanation!