Making "super" work outside a literal?

Axel Rauschmayer axel at rauschma.de
Sun Jun 19 21:13:34 PDT 2011


>>> If you really want to change what super means in a function expressed in an object initialiser, I'd like to see the exact use-case.
>> 
>> The only use case would be assigning a function that uses "super" to a property.
> 
> Such an assignment might need the meaning of super to remain the same, though. What's the use-case for remapping it? Stealing methods from one class to another whose static super is not the same object as the proto of the object into which the stolen function reference is stored?


It wouldn’t be about stealing, but about setting up an object differently:

var obj = {
    foo: function (x) {
        super.foo(x);
    }
};

=== VERSUS ===

var obj = {};
obj.foo = function (x) {
    super.foo(x);
};

The <| helps to make that less urgent (I often use Object.create() and then add properties via assignment, to avoid the verbosity of property descriptors).

-- 
Dr. Axel Rauschmayer

axel at rauschma.de
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com





More information about the es-discuss mailing list