Re:ES6: The features I'm most excited about
by v413 on Monday July 06, 2015 @02:41AM
(#9837213)
With the introduction of arrow function you won't need to use .bind(this) as arrow functions capture in their lexical scope the variables/keywords: this, arguments, super.
Re:ES6: The features I'm most excited about
by kriro on Monday July 06, 2015 @03:50AM
(#9837484)
Yes, maybe my comment wasn't clear. I meant to say add ".bind(this)" as a case that is replaced by => just like "var self = this;" or (...)(); for that matter.
e.g.
setTimeout(function(){alert(this.a)}.bind(this));
becomes simply
setTimeout(() => alert(this.a));