I am new to CoffeeScript. I have run into this today.
example ->
a ->
and
example ->
b =>
What this the different between a thin arrow vs a fat arrow?
Could someone please explain the difference and when they should be used.
The fat arrow =>
defines a function bound to the current value of this
.
This is handy especially for callbacks.
Notice the generated differences
Coffee script:
foo = () -> this.x + this.x;
bar = () => this.x + this.x;
JavaScript
var bar, foo,
_this = this;
foo = function() {
return this.x + this.x;
};
bar = function() {
return _this.x + _this.x;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With