`super` and superclass constructor return values

Isiah Meadows isiahmeadows at gmail.com
Fri Oct 16 21:02:12 UTC 2015


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)
  }
}
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151016/2c1b8681/attachment.html>


More information about the es-discuss mailing list