I'm reading YUI2.8.1 source code yahoo/yahoo.js.
The YAHOO.lang.extend method is implemented this way http://github.com/yui/yui2/blob/master/build/yahoo/yahoo.js
I don't understand why it creates another F function. IMHO, below code should also work(ignoring overrides part)
function extend (subc, superc ) {
if (!superc||!subc) {
throw new Error("extend failed, please check that " +
"all dependencies are included.");
}
subc.prototype=new superc();
subc.prototype.constructor=subc;
subc.superclass=superc.prototype;
}
There must be reason that YUI implements it this way, but I cannot figure it out. Anybody can shed some light on this?
Thanks