function Animal(name) {
this.name = name;
}
Animal.prototype.getName = function() {
return this.name;
};
function Dog(name, breed) {
Animal.call(this, name);
this.breed = breed;
}
Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;
Dog.prototype.getName = function() {
return `Dog called ${Animal.prototype.getName.call(this)}`;
};
const myDog = new Dog('Rex', 'German Shepherd');
console.log(myDog.getName()); Post #2283
4.79K
CHALLENGE
- 🔥 5
- ❤ 1
- 👍 1