Junior From PDF JavaScript 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
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details