Allen Wirfs-Brock allen at
Fri Jun 13 12:40:48 PDT 2014

On Jun 13, 2014, at 12:07 PM, Jussi Kalliokoski wrote:

> function Foo () {}
> Foo.prototype[Symbol.create] = null;

@@create methods are normally defined as methods of the constructor function rather than as an instance method on the prototype. So the above should be:

Foo[Symbol.create] = null;

> // ???
> // Maybe error out, like currently host objects without [[Construct]]:
> // TypeError: Foo is not a constructor.
> new Foo();

as currently specified [1] (and after I fix a bug I just noticed) it will fall back to doing the equivalent of Object.create(). 

I did that to maximize backwards compatibility for this specific situation:

function Foo() {};
Foo.__proto__ = null; //in ES6 default @@create inherited from Function.prototype becomes unavailable
new Foo;    //but in ES1-5 this still does the equivalent of Object.create();

If we go down the route of eliminating [[Construct]] and are willing to break backwards compat. for this case, then we could make 'new' throw if a constructor doesn't have a callable @@create.  That would provide a good way to indicate that a function is not a constructor (which is current determine based upon it having a [[Construct]] internal method.


More information about the es-discuss mailing list