extends null
Glen Huang
curvedmark at gmail.com
Thu May 7 09:49:29 UTC 2015
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)
I can't think of a better way of extending null, but I wonder what's the use case? null usually represents lacking of a value, and extending the lacking of a value? My brain hurts.
> On May 7, 2015, at 4:25 PM, Axel Rauschmayer <axel at rauschma.de> wrote:
>
> Is this the best way to use `extends null`?
>
> ```js
> class C extends null {
> constructor() {
> let _this = Object.create(C.prototype);
> return _this;
> }
> }
> ```
>
> You can’t use `this`, because it can’t be initialized via a super-constructor call: the super-constructor is `Function.prototype` (which can’t be constructor-called).
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de <mailto:axel at rauschma.de>
> rauschma.de
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150507/be5e48ab/attachment.html>
More information about the es-discuss
mailing list