es-discuss Digest, Vol 52, Issue 117

Peter Michaux petermichaux at gmail.com
Mon Jun 20 14:51:55 PDT 2011


On Mon, Jun 20, 2011 at 1:27 PM, Axel Rauschmayer <axel at rauschma.de> wrote:
> Terminology (created by me, but I think it explains well what is going on):
> - |this| points to the object where property lookup starts. It always points
> to the beginning of the prototype chain.
> - |here| points to the object where a property was found. |here| can point
> to any object in the prototype chain.
> |super| starts property lookup in the prototype of |here|, but does not
> change |this|. That is, a method invoked via |super| still has the same
> |this| and property lookup via |this| is unchanged. If the super-method
> again uses |super|, then property lookup will begin in the prototype of
> |here| (= where the super-method has been found). Etc.

It doesn't seem quite right that an upward call like

    Object.getPrototypeOf(here).foo.call(this)

has sugar

    super.foo()

but sideways calls like

  here.foo.call(this)

don't have any sugar.

By the way, I like this idea that "super" is available all the time
(not just in an initializer) like "this" is always available; however,
adding another implicit variable "here" which is dynamic like "this"
is disconcerting as "this" has been quite a wild beast in JavaScript
to say the least.

Peter


More information about the es-discuss mailing list