If a class extends another class, its constructor needs to call the super constructor before referencing this or accessing properties through super. Failure to do so will cause a runtime error.

Insert a super constructor call.

In the following example, class A extends class B, but its constructor assigns to this.x without first invoking the super constructor, which will cause a runtime error.

class A extends B { constructor() { this.x = 42; } }

To prevent the error, a super constructor call should be inserted:

class A extends B { constructor() { super(); this.x = 42; } }
  • Mozilla Developer Network: Sub classing with extends.