class Animal {
constructor(name) { this.name = name; }
}
class Dog extends Animal {
bark() { return 'woof'; }
}
new Dog('Rex').bark(); // 'woof'extends creates a child class that inherits all of the parent's methods.
The extends keyword allows a class to inherit from another class. The subclass gets all the methods and properties of the parent class.
Challenge: Create a subclass that inherits methods from a parent class.