What is JavaScript supertype?

Tell us what’s happening:

Hello again!

I’m trying to do this exercise, but I don’t understand how the supertype is linked to the rest of the code?

Your code so far


function Cat(name) {
this.name = name;
}

Cat.prototype = {
constructor: Cat,
eat: function() {
  console.log("nom nom nom");
}
};

function Bear(name) {
this.name = name;
}

Bear.prototype = {
constructor: Bear,
eat: function() {
  console.log("nom nom nom");
}
};

function Animal() { }

Animal.prototype = {
constructor: Animal,

};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Use Inheritance So You Don’t Repeat Yourself

Link to the challenge:

Hello,

Following two challenges will explain how supertype will be linked to the rest of the code.

You will write something like this to connect Cat to Animal:

Cat.prototype = Object.create(Animal.prototype);

Then when you create a new cat instance like:

let garfield = new Cat("Garfield);

garfield will be able to use all the methods defined in Animal.prototype.