domenic at domenicdenicola.com (2014-06-20T19:42:48.910Z)
> One question about @@create though... What would this do:
>
> ```js
> function Foo () {}
>
> Foo.prototype[Symbol.create] = null;
>
> // ???
> // Maybe error out, like currently host objects without [[Construct]]:
> // TypeError: Foo is not a constructor.
> new Foo();
> ```
```javascript
function Foo(){}
Object.defineProperty(Foo, Symbol.create, {value: null});
new Foo();
```
Results in `uncaught exception: TypeError: "Symbol(Symbol.create)" is
not a function`.
Whereas this version creates a default object with [[Prototype]] set to
`Bar.prototype`:
```javascript
function Bar(){}
Object.defineProperty(Bar, Symbol.create, {value: void 0});
new Bar();
```
The exact behaviour is specified in CreateFromConstructor(F) and
Construct(F, argumentsList)
-
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-createfromconstructor
-
https://people.mozilla.org/~jorendorff/es6-draft.html#sec
> One question about @@create though... What would this do: > > function Foo () {} > > Foo.prototype[Symbol.create] = null; > > // ??? > // Maybe error out, like currently host objects without [[Construct]]: > // TypeError: Foo is not a constructor. > new Foo(); > > - Jussi ```javascript function Foo(){} Object.defineProperty(Foo, Symbol.create, {value: null}); new Foo(); ``` Results in `uncaught exception: TypeError: "Symbol(Symbol.create)" is not a function`. Whereas this version creates a default object with [[Prototype]] set to `Bar.prototype`: ```javascript function Bar(){} Object.defineProperty(Bar, Symbol.create, {value: void 0}); new Bar(); ``` The exact behaviour is specified in CreateFromConstructor(F) and Construct(F, argumentsList) - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-createfromconstructor - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-construct-f-argumentslist