Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

super method with class 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()*/
 
PREVIOUS NEXT
Tagged: #super #method #class #javascript
ADD COMMENT
Topic
Name
1+3 =