Junior JavaScript

What is super()?

super() calls the parent class constructor. Must be called before using this in

subclass.

Example:

class Animal {

constructor(name) { this.name = name; }

class Dog extends Animal {

constructor(name, breed) {

super(name);

this.breed = breed;

More from JavaScript Tutorial

All questions for this course