Making "super" work outside a literal?

Brendan Eich brendan at
Thu Jun 23 22:47:35 PDT 2011

On Jun 23, 2011, at 10:39 PM, Axel Rauschmayer wrote:

>>> Related topic: How would |super| be handled if |this| is lexical?
>> There's no connection, AFAIK. But we also don't have a lexical-this proposal in Harmony yet.
> I would expect problems that are similar to that = this:
> var obj = {
>    mymethod: function(arr) {
>        arr.forEach(function(x) {
>            super.mymethod(x); // would this work?
>        });
>    }
> }

From :

PrimaryExpression : ...
The value of super is the same as the value of this but when super is used as the base of a property access the property lookup starts with the object that is the prototype of the object defined by the object literal that contains the reference to super.

This seems to say that the wrong |this| would be used, with the right property lookup starting point. Yikes.

> Thankfully, I don’t think that super-calls will be very common in typical JavaScript code, in contrast to "this".

Not sure this will all pan out as proposed. 'super' in classes works. 'super' in any function nested however deeply in an object initialiser, perhaps not. If the above spec constrained the nesting to be immedate method of, that would seem to solve it. But would that be too restrictive?


> -- 
> Dr. Axel Rauschmayer
> axel at
> home:
> blog:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list