super() on class that extends

Kyle Simpson getify at
Fri Apr 10 21:22:52 UTC 2015

Neither the base (parent) nor derived (child) class requires a constructor, nor does the child class require a `super()` call. If you omit either constructor, an assumed one is present. However, if you *do* declare a constructor in a derived class, you'll need to call `super()` in it.

So, to the point of your original question, this is totally valid:

class A {
  foo() { console.log("A:foo"); }

class B extends A {
  bar() {; }

var x = new B();; // A:foo

See it in action:

More information about the es-discuss mailing list