class Animal {
constructor(name) { this.name = name; }
speak() { return `${this.name} makes a sound.`; }
}
class Dog extends Animal {
speak() {
return `${super.speak()} Specifically, a bark!`;
}
}
new Dog('Rex').speak();
// 'Rex makes a sound. Specifically, a bark!'Tip
super() must be called before using 'this' in a subclass constructor — a very common gotcha.