what kind of problem is this fat arrow feature trying to solve ?

Brendan Eich brendan at mozilla.com
Wed Oct 2 11:01:03 PDT 2013


Andrea Giammarchi wrote:
> fat arrow does not add any capabilities but create the need to be sure 
> about the context.

This does not make sense. The problem of being unsure about "which this" 
already exists. Adding arrows does not make it worse. The new syntax 
makes it better, compared to 'var self = this;' or .bind(this) hacks 
that are more verbose and easy to forget -- that is, whose absence is 
easy to overlook.

> In use strict fat arrow will bring a lovely `undefined` wich is 
> undesired so nothing is solved in there.

Stop comparing apples to oranges. If we have today

"use strict";
function foo() {
   ...
   setCallback(function () { ... this ...}.bind(this));
}


Then you have no greater or lesser incidence of undefined-this bugs due 
to someone calling foo() instead of foo.call, foo.apply, or obj = 
{method:foo}, obj.method() by changing this code to use an arrow:

"use strict";
function foo() {
   ...
   setCallback(() => {... this ...});
}


If you don't like strict mode, keep that out of this thread. Incidence 
of undefined-this bugs due to it do not change with arrows.

/be


More information about the es-discuss mailing list