new instantiation design alternatives

Allen Wirfs-Brock allen at
Thu Sep 18 12:21:08 PDT 2014

On Sep 18, 2014, at 11:29 AM, Dmitry Lomov wrote:

> You haven't specified the constructor body, I assume you have intentionally omitted it, and in that case the above is equivalent to
> class A extends HTMLElement {
>     constructor() {
>        this = new super();
>     }
> }
> There is no explicit passing of new^ here.
> new^ is really just for 'constructors that are callable as functions as well'. Andreas is right that it is esoteric, but supporting that seems to be a requirement for classes design.

But just so there is no confusion, there is implicit passing of new^ going on in this example. That's necessary in order for HTMLElement to correctly the the [[Prototype]] of the object allocates.


More information about the es-discuss mailing list