To inherit features from a class, we need to use the extends
keyword in the class definition.
By coding extends
, we'll make the Dog
class inherit from the Animal
class.
class Animal {
constructor(name) {
this.name = name;
}
}
class Dog extends Animal {}