extending an ES6 class using ES5 syntax?

Rob Brackett rob at robbrackett.com
Fri Mar 30 04:53:23 UTC 2018

> Why is it that the static version you implemented above can `.apply` itself without this same error (and `new` is not being used)?

Wow, this is old stuff! Anyway, it’s because it never calls the built-in `apply` on itself:

class FunctionInheritable {
  //…other bits omitted…

  static apply(context, args) {
    // this calls `apply` on `_constructor`, which is a function, not `constructor`, which is a class constructor
    return this.prototype._constructor.apply(context, args) || context;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180329/c66674a8/attachment.html>

More information about the es-discuss mailing list