jashkenas/coffee-script — Issue #2184: use of `this` in a fat arrow function
Author: jclevy
Created: 2012-03-08 14:23:12+00:00
State: open

This code :

this.c = 1

f = () =>
a=`this`.c
b=`this.c`
a is b

alert f()

is translated to :

var f,
_this = this;

this.c = 1;

f = function() {
var a, b;
a = _this.c;
b = this.c;
return a === b;
};

alert(f());

Is this correct ?

I thought instead of :

a = _this.c;
b = this.c;

we would have :

a = this.c;
b = this.c;