Tell us what’s happening:
i did the code correct, but I just want to understand how does the programm knows, that animal.prototype refers/is conected to any instanceof.bear/cat?
i did the code correct, but I just want to understand how does the programm knows, that animal.prototype refers/is conected to any instanceof.bear/cat?
function Cat(name) {
this.name = name;
}
Cat.prototype = {
constructor: Cat,
};
function Bear(name) {
this.name = name;
}
Bear.prototype = {
constructor: Bear,
};
function Animal() { }
Animal.prototype = {
constructor: Animal,
eat: function() {
console.log("nom nom nom");
}
};
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44
Challenge: Use Inheritance So You Don’t Repeat Yourself
Link to the challenge: