en.javascript.info/1-js/09-classes/02-class-inheritance/1-class-constructor-error/solution.md
2019-04-21 13:40:20 +03:00

27 lines
391 B
Markdown

That's because the child constructor must call `super()`.
Here's the corrected code:
```js run
class Animal {
constructor(name) {
this.name = name;
}
}
class Rabbit extends Animal {
constructor(name) {
*!*
super(name);
*/!*
this.created = Date.now();
}
}
*!*
let rabbit = new Rabbit("White Rabbit"); // ok now
*/!*
alert(rabbit.name); // White Rabbit
```