class Vehicle {
constructor(type) {
this.type = type;
}
describe() {
return `I am a ${this.type}`;
}
}
class Car extends Vehicle {
constructor(brand) {
super("car");
this.brand = brand;
}
describe() {
return `${super.describe()} made by ${this.brand}`;
}
}
const myCar = new Car("Toyota");
console.log(myCar.describe());
console.log(myCar instanceof Car);
console.log(myCar instanceof Vehicle);
console.log(Object.getPrototypeOf(Car) === Vehicle);
Post #3023
2.81K
CHALLENGE
- 👍 6
- 🔥 5
- ❤ 1