extending an ES6 class using ES5 syntax?

/#!/JoePea joe at trusktr.io
Mon Apr 2 19:52:22 UTC 2018


Ah, makes sense. Thanks! - Joe

*/#!/*JoePea

On Thu, Mar 29, 2018 at 9:53 PM, Rob Brackett <rob at robbrackett.com> wrote:

> 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;
>   }
> }
> ```
>
> -Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180402/f5280de1/attachment.html>


More information about the es-discuss mailing list