老师请问一下,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);//Animalvar F = function(){};
F.prototype = Animal.prototype;
Cat.prototype = new F();
Cat.prototype.constructor = Cat;
alert(Cat.prototype.constructor);//Cat
alert(Animal.prototype.constructor);//Animal2015-06-17
举报