extending an ES6 class using ES5 syntax?

Rob Brackett rob at robbrackett.com
Sat May 14 02:51:38 UTC 2016

If it's helpful, you can look at how newless handles this: https://github.com/mr0grog/newless/

It's a little more complicated than the earlier replies because many implementations have classes but not `Reflect.construct`, but it goes gracefully allow ES5- function-style constructors to inherit from class-style constructors.

At the end of the day, the one restriction you can't really work around is not being able to touch `this` inside the constructor before calling the super class’s constructor (unless you don't call it at all, though that will no longer work if/when you transition to proper classes).


On May 13, 2016, at 6:35 PM, Renki Ivanko <fatalis.erratum at gmail.com> wrote:

>> That said, can't the right thing be done using Reflect.construct?
> It can:
> ```js
> function B() {
> 	return Reflect.construct(A, arguments)
> }
> ```
> `instanceof B` will be `false`, though.
> _______________________________________________
> 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/20160513/276bcac5/attachment.html>

More information about the es-discuss mailing list