The problem is that ... when you issue the line:
sub2.prototype = core.prototype;
You use the SAME prototype on sub2how core, so when you call .output()from ANY of the classes, the function in core.prototype.outputis the version sub2, since it is defined last, Remember that the assignment of objects occurs by reference.
To copy an object that you usually see:
sub2.prototype = new core();
sub2.prototype.core = core;
- , jQuery $.extend(sub1.prototype, core.prototype); . jQuery, :
sub2.prototype = {};
for (var method in core.prototype) sub2.prototype[method] = core.prototype[method];
sub2.prototype.constructor = core;
sub2.prototype.core = core;