Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Inheritance In JavaScript


class Animal{

  constructor()
  {
    this.walk = "walk";
  }
}
class Dog extends Animal{
constructor()
{
  super();
this.bark = "bark";
}

}

const dog = new Dog();
console.log(dog.walk);
/*must include BOTH extends and super()*/
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #Inheritance #In #JavaScript
ADD COMMENT
Topic
Name
4+5 =