`super` and superclass constructor return values
Eric Faust
efaust at mozilla.com
Fri Oct 16 21:24:31 UTC 2015
Hi Isiah,
My understanding is that this should log "true". Class constructors may
return any object they wish, and needn't return instances of the class.
Hopefully, this will allow you to simplify.
Thanks,
Eric
On Fri, Oct 16, 2015 at 2:02 PM, Isiah Meadows <isiahmeadows at gmail.com>
wrote:
> What should `this` be in class `B`? The value of `object` or an instance
> of `B`? It's an edge case, but could simplify my code a little if it's the
> former.
>
> ```js
> const object = {}
>
> class A {
> constructor() {
> return object
> }
> }
>
> class B extends A {
> constructor() {
> super()
> console.log(this === object)
> }
> }
> ```
>
> _______________________________________________
> 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/20151016/3c23bd60/attachment-0001.html>
More information about the es-discuss
mailing list