http://aralejs.org/class/docs/competitors.html
http://javascript.crockford.com/prototypal.html
Here is another formulation:
Object.prototype.begetObject = function () { function F() {} F.prototype = this; return new F(); }; newObject = oldObject.begetObject();
2007-04-02
The problem with the object
function is that it is global, and globals are clearly problematic. The problem with Object.prototype.begetObject
is that it trips up incompetent programs, and it can produce unexpected results when begetObject
is overridden.
So I now prefer this formulation:
if (typeof Object.create !== ‘function‘) { Object.create = function (o) { function F() {} F.prototype = o; return new F(); }; } newObject = Object.create(oldObject);
2008-04-07
原文:http://www.cnblogs.com/danghuijian/p/4009971.html