prototype ,它也继承了supertype的构造函数属性。这是一个例子: 函数Bird(){}但
Bird.prototype = Object.create(Animal.prototype);
let duck = new Bird();
duck.constructor // function Animal(){...}
duck和所有Bird实例都应该表明它们是由Bird而不是Animal建造的。为此,您可以手动将Bird's构造函数属性设置为Bird对象: Bird.prototype.constructor = Bird;
duck.constructor // function Bird(){...}
duck.constructor和beagle.constructor返回各自的构造函数。 Bird.prototype应该是Animal一个实例。
testString: 'assert(Animal.prototype.isPrototypeOf(Bird.prototype), "Bird.prototype should be an instance of Animal.");'
- text: duck.constructor应该返回Bird 。
testString: 'assert(duck.constructor === Bird, "duck.constructor should return Bird.");'
- text: Dog.prototype应该是Animal一个实例。
testString: 'assert(Animal.prototype.isPrototypeOf(Dog.prototype), "Dog.prototype should be an instance of Animal.");'
- text: beagle.constructor应该返回Dog 。
testString: 'assert(beagle.constructor === Dog, "beagle.constructor should return Dog.");'
```