prototype от другого объекта, он также наследует свойство конструктора supertype . Вот пример: function 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 and beagle.constructor return their respective constructors.
Bird.prototype should be an instance of Animal.
testString: assert(Animal.prototype.isPrototypeOf(Bird.prototype));
- text: duck.constructor should return Bird.
testString: assert(duck.constructor === Bird);
- text: Dog.prototype should be an instance of Animal.
testString: assert(Animal.prototype.isPrototypeOf(Dog.prototype));
- text: beagle.constructor should return Dog.
testString: assert(beagle.constructor === Dog);
```