Referencing `super`

Domenic Denicola domenic at
Tue Aug 5 20:20:39 PDT 2014

I sympathize; I have always found the fact that bare `super()` works to be confusing.
From: Brett Andrews<mailto:brett.j.andrews at>
Sent: ‎2014-‎08-‎05 23:09
To: Allen Wirfs-Brock<mailto:allen at>
Cc: es-discuss at<mailto:es-discuss at>
Subject: Re: Referencing `super`

Thanks for your response, Allen. I'm not sure what convincing I can do. To me it seems odd that `super()` is the same as `super.submit()` but `super` is not the same as `super.submit`, but perhaps to others that seems perfectly fine. An alternative to this suggestion would be `super()` should not be the same as `super.submit()`; and instead `super()` is either illegal or calls `constructor`.


On Wed, Aug 6, 2014 at 11:37 AM, Allen Wirfs-Brock <allen at<mailto:allen at>> wrote:

On Aug 5, 2014, at 6:06 PM, Brett Andrews wrote:

Some differences/oddities I noticed between referencing and invoking `super`. I briefly discussed this with Erik Arvidsson at In essence, if you can invoke in two seperate ways, it seems logical that you should be able to reference in those two ways (super() ~= super.submit(); super != super.submit).

class ClientForm extends Form{
  submit() {
    super.submit(); // Invokes Form.submit
    let superSubmit = super.submit; // Reference to Form.submit
    superSubmit(); // Invokes, but `this` is now undefined; not sure if intended

just like:
        this.submit(); // Invokes ClientForm.submit
        let thisSubmit = this.submit;  //Reference to ClientForm.submit
        thisSubmit();   //invokes, but 'thts' in now undefined

This is how properties and method invocations work in JS.  All that the use of 'super' does is change the place the property lookup starts.  Otherwise 'super' is equivalent to 'this' in the above code.

    super(); // Invokes Form.submit
semantically equivalent to
just a short cut

    let superSubmit2 = super; // Error: "Unexpected token ;"

in some languages, such a unqualified 'super' reference would be equivalent to 'this'.
We intentionally made it an error for that reason.  I perhaps could be convinced that it should mean the same as 'super.submit'.
But in that case,
would still not be the same thing as


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

More information about the es-discuss mailing list