Concepts

Derived constructor

Try the free JavaScript compiler

Constructor whose normal receiver is established by super. Derived instance fields initialize during the super call after base construction. Explicit object returns can bypass normal receiver creation.

Formal Syntax & Structure

javascript syntaxjavascript
class Child extends Parent { constructor() { super(); } }

Working Example

Example Snippetjavascript
class B{constructor(){this.n=3;}}class C extends B{twice=this.n*2;constructor(){super();this.n=5;}}console.log(new C().twice);
JavaScript Reference