You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Class inheritance is a feature that enables certain classes to take all the methods and properties of another one (parent class) and makes it possible to extend the parent class by adding more
class Dog extends Animal {
constructor (name, age, breed) {
super(name, age);
this.breed = breed;
}
bark() {
return 'Bark';
}
}
class Cat extends Animal {
constructor (name, age, weight){
super(name, age);
this.weight = weight;
}
}
const myDog = new Dog('Rex', 2, 'German Shepherd');