On Oct 1, 2011, at 4:23 PM, Lasse Reichstein wrote: > On Sat, Oct 1, 2011 at 2:16 PM, Axel Rauschmayer <[email protected]> wrote: > Then a super-call is always about letting "this" stay the same, but finding a > "later" method: If your method lives in O1, you start your search for the > super-property *after* O1 etc. In code this looks as follows: > here.__proto__.foo.call(this, …) > where "here" means "the object that the current method lives in". The effect > is then: > - here.__proto__: start your search *after* the method’s object and look for > "foo". > - .call(this, …): but keep "this" the same. > > Am I right that super-calls only works for class methods, because they know > the, statically determinable, prototype chain of its instances, and therefore > it knows where to start the search. > > A normal method, e.g., > var o = {__proto__: { m: function(x) { alert(x); }}; > o.m = function(v) { super(v); }; // doesn't work
You'd write super.m(v) there. See http://wiki.ecmascript.org/doku.php?id=harmony:object_initialiser_super /be > o.m("hello"); > won't be able to use "super", because it doesn't know where to start the > search - all it knows is the this-argument to the call and the function > itself, which doesn't necessarily mean anything. > > /L > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

