The `super` keyword doesn't work as it should?

/#!/JoePea joe at
Mon Jul 25 02:04:33 UTC 2016

It doesn't make sense because then `super` isn't really referring to the
super class that the method is used on. I think it makes more sense for
`super` to take meaning depending on where the method is found, not where
it is defined.

What if there was also something like `Function.prototype.bind` like
`Function.prototype.with`, so `someFunc.with(homeObject)` returns a new
function who's [[HomeObject]] is the specified `homeObject`. It would be
possible to do `someFunc.with(...).bind(...)` to configure both the home
object and `this`.


On Thu, Jul 21, 2016 at 3:21 AM, Claude Pache <claude.pache at>

> There is probably no way to make the `super` semantics just work in all
> use cases. But I think that the choice made in ES6 is the right one in
> order to have it correctly working in the most naïve (and maybe the most
> common?) use cases of method borrowing, i.e., when you don’t have knowledge
> of — or even you wilfully ignore — its implementation details. Consider for
> example:
> ```js
> class MyArray extends Array {
>     forEach(callback, thisArg) {
>         // ...
>         super.forEach(callback, thisArg)
>         // ...
>     }
> }
> ```
> and somewhere else:
> ```js
> NodeList.prototype.forEach = MyArray.prototype.forEach // or: (new
> MyArray).forEach
> HTMLCollection.prototype.forEach = MyArray.prototype.forEach
> ```
> Here, I expect that `super.forEach` will continue to point to
> `Array.prototype.forEach`. This is because I’m thinking of
> `MyArray.prototype.forEach` as a black box that should not change its
> behaviour just because I’m moving it around, as it is generally the case
> with methods of the builtin library.
> —Claude
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list