How to fix the `class` keyword (Brendan Eich)

Eric Elliott eric at
Fri Mar 6 00:52:44 UTC 2015

> In case it helps, the idea mooted for ES7 is that you'd add a "call
> handler" to the class for when it is invoked without `new`:
>   class Point2D {
>     constructor(x, y) { this.x = x, this.y = y; }
>     [](x, y) { return new this.constructor(x, y); }
>     ...
>   }
> I used `this.constructor`, but of course using `Point2D` directly is
> possible. In that case, subclasses would have to override the
> `[]` method, which seems undesirable and easily avoided as shown
> above.
> Bottom line, we don't want an implicit call handler in ES6. We need to get
> this right in ES7, and failing hard for now is the only way to be
> future-proof.
> /be

Thanks Brendan. This is very helpful indeed! Where can I learn more about
that solution?

I assume for backwards compatibility, this will not be default behavior, so
we're going to have to remember to use this boilerplate with every class if
we don't want them to be broken, right?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list