There are two things here: - In JS I (as well as most code in libraries I read) tend to use function expressions a lot. The arrow notation is easier to read in my opinion. It's shorter and more concise. That's a weak argument for it, but I think just making the language more concise is an argument on its own.
- While we're making function expressions shorter, let's fix `this` function expresisons. Pretty much every host environment be it node, the web browser or embedding uses deferred execution and event loop driven concurrency at some level. While there is nothing in JavaScript itself that dictates this sort of concurrency in practice events are used extensively when coding JavaScript. Using an object and adding handlers that need a reference to that object is very common in the browser and in node. It's very common in practice and having lexical this in arrow functions seems very useful. An indicator might be that in languages that support it like CoffeeScript you see it used all the time, and the fact you see people using the `this=that/self/_this` ""pattern"" all the time. That pattern introduces its own set of problems - for example it creates a closure scope where one might not be needed and it's boilerplate. Having fat arrow lets us solve that. Benjamin Gruenbaum ---------- Forwarded message ---------- From: Andrea Giammarchi <[email protected]> To: "Tab Atkins Jr." <[email protected]> Cc: "[email protected]" <[email protected]> Date: Tue, 1 Oct 2013 19:35:28 -0700 Subject: Re: what kind of problem is this fat arrow feature trying to solve ? setTimeout accept extra arguments ... I write JavaScript that uses this feature. `setTimeout(callback, delay, arg1, arg2, argN, evenAnObject);` so fat arrow does not solve much here, I can use self as first argument and I am good. `forEach` and all other arrays accept a second argument `array.forEach(doStuff, boundContextObject);` so fat arrow does not solve a thing in mostly all Array extras. for **DOM** I use handlers as specified by **W3C** so that `{handleEvent: function () {this}}` works better than any mess I could create with callbacks that I won't be unable to remove later on (as I've said) ... so I can use `removeEventListener(this)` in every method handled by that object. So I actually wonder what kind of JavaScript **you** write because this was a honest question but probably ... people not familiar with JS are the answer: since developers ignore part of JS specs available since every then we need a fat arrow to break old syntax to make the creation of self bound function easier. This would be already an answer so thanks for participating. br
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

