老師請問一下,javascript利用空對象作為中介,是如何實現不改變父類原型的屬性的啊?
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-17
舉報
2015-06-18
原型繼承機制有點,牽線傳輸的味道.