> Le 7 mai 2015 à 11:49, Glen Huang <curvedm...@gmail.com> a écrit :
> 
> Isn't super-constructor null in this case?
> 
> From step 4 in 
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-getsuperconstructor 
> <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-getsuperconstructor>
> 
> superConstructor is C.[[GetPrototypeOf]]()
> 
> which should be `null` after the class definition, if I'm not wrong. (But it 
> finally throws due to type error, so technically speaking, you can't even 
> reference the super constructor)

No, as a special case of the `extends` semantics, `C.[[GetPrototypeOf]]()` will 
be %FunctionPrototype%; see step 6.e.ii of:
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-classdefinitionevaluation

The reason is presumably that, since the constructor is a function, it should 
always have the methods for functions (`.bind`, `.call`, etc.) on its prototype 
chain.

The true meaning of `C extends null` is the following: The instances of `C` 
won’t have %ObjectPrototype% in their prototype chain. (For the use cases, 
don’t ask me.)

—Claude
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to