new instantiation design alternatives

Boris Zbarsky bzbarsky at mit.edu
Wed Sep 17 10:24:36 PDT 2014


On 9/17/14, 1:15 PM, Andreas Rossberg wrote:
> In the light of that, I'm stilling missing the
> compelling reason to introduce new^ at all.

Say you have:

   class A extends B {
     constructor() {
       this = new super();
     }
   };

   class B {
     constructor() {
        // what here?
     }
   };

(apologies for any obvious syntax mistakes).

And then you do:

   var a = new A();

This will delegate the object construction to B.  How does B know to 
create the object with A.prototype as the prototype?

In the new^ world, this is fairly straightforward.  B's constructor does:

   this = Object.create(new^.prototype);

Without new^, how does this work?

-Boris


More information about the es-discuss mailing list