In the code in question, in the Bird class there is a typo, the first letter c is not English, which makes the described method not a constructor, but the usual method.
If corrected, then the error of using super will go away.
class Animal { constructor(name, voice) { this.name = name; this.voice = voice; } say() { console.log(`${this.name} said ${this.voice}`); } } class Bird extends Animal { constructor(name, voice, canFly) { super(name, voice); this.canFly = canFly; } } const duck = new Bird('Dick', 'Crack'); duck.say(); duck.say();
Why do you need super in this case?
In order to be able to call the constructor of the base class, and initialize all the necessary fields.
If it was not called, it was decided at the language level to forbid access to this , which points to the object being created, since it may not be initialized.
Another example of using the super keyword is to refer to the fields and methods of the base class, for example:
class Animal { constructor(name, voice) { this.name = name; this.voice = voice; } say() { console.log(`${this.name} said ${this.voice}`); } } class Bird extends Animal { constructor(name, voice, canFly) { super(name, voice); this.canFly = canFly; } say() { console.log('Bird say'); super.say(); } } const duck = new Bird('Dick', 'Crack'); duck.say(); duck.say();
More information about super can be found in the help .