01 / 06
Methods come over too
It is not only the constructor that comes over. Methods work as they stand as well.
There is no run written in the child class and yet b.run() works. When you call, it looks in the child class first and goes to the parent class if it is not there.
class Vehicle { constructor(name) { this.name = name; } run() { console.log(`${this.name} runs`); }}class Bicycle extends Vehicle {}const b = new Bicycle("red bike");b.run();Result
red bike runs