extends null
Claude Pache
claude.pache at gmail.com
Thu May 7 10:55:15 UTC 2015
> Le 7 mai 2015 à 11:49, Glen Huang <curvedmark at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150507/88ebb89c/attachment-0001.html>
More information about the es-discuss
mailing list