extends null

Glen Huang curvedmark at gmail.com
Thu May 7 11:14:27 UTC 2015

Ah, didn't notice the special case, thanks for the heads up.

Having methods for function in the prototype chain makes sense.

Another related question: If I want to override a superclass's constructor(), without calling it, I should do something like this?

class A extends B {
   constructor() {
       let _this = Object.create(new.target.prototype);
       return _this;

Anyway to use `this` here? Having to use a different name is a bit painful.

> On May 7, 2015, at 6:55 PM, Claude Pache <claude.pache at gmail.com> wrote:
>> Le 7 mai 2015 à 11:49, Glen Huang <curvedmark at gmail.com <mailto: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 <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/c1428658/attachment.html>

More information about the es-discuss mailing list