new instantiation design alternatives

Dmitry Lomov dslomov at
Thu Sep 18 11:29:29 PDT 2014

On Thu, Sep 18, 2014 at 6:57 PM, Boris Zbarsky <bzbarsky at> wrote:

> On 9/18/14, 12:51 PM, Andreas Rossberg wrote:
>> Well, nothing has to go there. Since B does not have an extends
>> clause, it has -- according to Allen's gist -- its `this` initialized
>> implicitly (with an object having the derived constructor's prototype,
>> like you want).
> Wait.  How does the |new super()| invocation know what prototype to use,
> exactly?  Is it basically passing in the new^ value as some sort of hidden
> state under the hood without exposing it with a name?

Yes, exactly.

>  What new^ adds to the table is the ability to bypass this mechanism
>> and implement non-standard inheritance or creation patterns within the
>> class syntax.
> Well, it adds the ability to explain what happens when you do:
>    class A extends HTMLElement {
>       ...
>    }
> right?

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.

Google Germany GmbH
*Dienerstr. 12, 80331 München., DE *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list