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 www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #Inheritance #In #JavaScript
ADD COMMENT
Topic
Name
2+4 =