--- id: 587d7db1367417b2b2512b86 title: Reset an Inherited Constructor Property challengeType: 1 videoUrl: '' localeTitle: Сбросить свойство унаследованного конструктора --- ## Description
Когда объект наследует свой 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 () {...}
## Instructions undefined ## Tests
```yml tests: - text: '' testString: 'assert(Animal.prototype.isPrototypeOf(Bird.prototype), "Bird.prototype should be an instance of Animal.");' - text: '' testString: 'assert(duck.constructor === Bird, "duck.constructor should return Bird.");' - text: '' testString: 'assert(Animal.prototype.isPrototypeOf(Dog.prototype), "Dog.prototype should be an instance of Animal.");' - text: '' testString: 'assert(beagle.constructor === Dog, "beagle.constructor should return Dog.");' ```
## Challenge Seed
```js function Animal() { } function Bird() { } function Dog() { } Bird.prototype = Object.create(Animal.prototype); Dog.prototype = Object.create(Animal.prototype); // Add your code below this line let duck = new Bird(); let beagle = new Dog(); ```
## Solution
```js // solution required ```