Use extends to create a subclass that inherits from a parent class.
class Animal {
speak() {
console.log("Some sound");
}
}
class Dog extends Animal {
speak() {
console.log("Woof!");
}
}
const dog = new Dog();
dog.speak(); // "Woof!"
The subclass inherits methods and can override them.