function Animal(){ this.species = "動物"; } function Cat(name,color){ this.name = name; this.color = color; } Cat.prototype = new Animal(); Cat.prototype.constructor = Cat; //Cat的原型指向了 Animal生成的對象,此時Cat 和Animal不是引用了同一個原型嗎 ,將Cat的構(gòu)造器覆蓋了 不也會同時覆蓋 Animal的構(gòu)造器嗎? 所以下面這句為什么不是false而是true alert(Animal.prototype.constructor == Animal); // true
javascript 原型問題
蕪湖不蕪
2018-12-22 02:34:50