Not forcing super in derived class's constructor?

Glen Huang curvedmark at
Fri May 8 03:05:03 UTC 2015

TLDR: If `this` is used without `super` (which should be statically analyzable), let it refer to Object.create( Otherwise, let super creates what it refers to.

I know the reason to force `super` in derived class's constructor is to make sure `this` refers to the exotic object the base class might allocate.

But I bet in real world, extending base classes who only create ordinary objects is more common than extending those create exotic objects. And forget to call super is going to be frequent mistake. In es5, when you extend a class like this

function Foo() {
Foo.prototype = Object.create(Bar.prototype);

`this` refers to Object.create( So I wonder if we can keep this behavior, making things less surprising when people transit to es 2015?

More information about the es-discuss mailing list