Object Oriented Programming - Use Inheritance So You Don't Repeat Yourself

Hi there i have a question about inheritance

in this code

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");


namely , i understand that Animal is a supertype of the two animals cat and bear and thus they are inheriting the method, however i do not understand where the link is ,

i assumed there would be some code to link the cat and bear as subtypes of the animal however i do not see where it is.

Please move to the next lesson. This is just the first step of several that are part of the inheritance lessons.

yes thank you i guess it was just missing then

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.