๐ฅUse of Super
class Animal {
constructor(name) {
this.name = name;
}
speak() {
console.log(`${this.name} makes a noise.`);
}
}
class Cat extends Animal {
constructor(name, breed) {
super(name);
this.breed = breed;
}
speak() {
console.log(`${this.name} meows.`);
}
}
const cat = new Cat('Fluffy', 'Siamese');
cat.speak();
// Output: "Fluffy meows."Last updated