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?
```js
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 <[email protected]> wrote:
>
>
>> Le 7 mai 2015 à 11:49, Glen Huang <[email protected]
>> <mailto:[email protected]>> 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
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss