Bound instance-function vending (was RE: Arrow binding)

Brendan Eich brendan at mozilla.org
Sun Apr 29 11:04:37 PDT 2012


Angus Croll wrote:
> On Apr 29, 2012, at 1:28, Brendan Eich<brendan at mozilla.org>  wrote:
>
>> Axel Rauschmayer wrote:
>>> I am not saying that the transition from the old rules to the new rules will be entirely painless, but if the new rules are simple, that pain is worth it, IMHO.
>> There are no new rules. Some functions ignore |this| or bind it rather than using it. These differences in kind do not change due to arrows.
>
> Is there lexical |this| binding in ES5?

The only relevant issue for my exchange with Axel was whether any kind 
of this-binding exists in ES5 or older. The answer is yes.

"Lexical this" is often wanted and of course simulated with var self = 
this; ... function (){...self...} or .bind (implementable in pure ES3). 
But the lexical part doesn't enter into the contract of the API taking 
the function argument. It's between the API caller and the function 
argument's implementation -- when the latter is a closure in the former, 
lexical |this| often wins.

/be


More information about the es-discuss mailing list