Comments on “Making Built-in Objects Subclassable”

Herby Vojčík herby at mailbox.sk
Mon Mar 18 04:42:54 PDT 2013



Axel Rauschmayer wrote:
> A few more thoughts:
>
> - This marks the end of prototypal inheritance in JavaScript (not
> complaining, just stating a fact). Putting @@create in constructors C
> makes a lot of sense, but it could, in principle, also be put into
> instance prototypes C.prototype. Then Object.create(proto) could use
> @@create to create the instance whose prototype is proto.

The identifier create is probably used in lots of other places, so this 
is non-starter, but if not, it could be simply reused, so that:

   Ctr.create(proto, [descriptors])

does

   newobj = Ctr[@@create]();
   newobj.__proto__ = proto;
   Object.defineProperties(newobj, descriptors);

It is semantically compatible with what Object.create does now.
In fact, if somewhere inside implementation of Object.create one would 
use "this[@@create]" to create new instance, and it was moved to 
Function.prototype, it could be used as is.

> Axel

Herby


More information about the es-discuss mailing list