More on Javascript Inheritance
I changed the syntax of the Mocha Inheritance code a bit, to what I think you'll agree is easier to read:
Function.prototype.inherit = function(fnc) {
var constr = this;
var Constructor = function(){
if (fnc)
fnc.apply(this, arguments);
constr.apply(this, arguments);
};
Constructor.prototype = new (fnc || this)();
Constructor.prototype.constructor = fnc || this;
return Constructor;
};
Prototype inheritance reduced to the max :-)
15.1.2007, 10:01