老師請問一下,javascript利用空對象作為中介,是如何實(shí)現(xiàn)不改變父類原型的屬性的?。?/h1>
var?F?=?function(){};
F.prototype?=?Animal.prototype;
Cat.prototype?=?new?F();
Cat.prototype.constructor?=?Cat;
alert(Cat.prototype.constructor);//Cat
alert(Animal.prototype.constructor);//Animal
var?F?=?function(){}; F.prototype?=?Animal.prototype; Cat.prototype?=?new?F(); Cat.prototype.constructor?=?Cat; alert(Cat.prototype.constructor);//Cat alert(Animal.prototype.constructor);//Animal
2015-06-18
原型繼承機(jī)制有點(diǎn),牽線傳輸?shù)奈兜?