title: When should I use arrow functions in ECMAScript 6?
body: <p>With <code>() =&gt; {}</code> and <code>function () {}</code> we are getting two very similar ways to write functions in ES6. In other languages lambda functions often distinguish themselves by being anonymous, but in ECMAScript any function can be anonymous. Each of the two types have unique usage domains (namely when <code>this</code> needs to either be bound explicitly or explicitly not be bound). Between those domains there are a vast number of cases where either notation will do.</p>
  <p>Arrow functions in ES6 have at least two limitations:</p>
  <ul>
  <li>Don't work with <code>new</code> and cannot be used when creating <code>prototype</code></li>
  <li>Fixed <code>this</code> bound to scope at initialisation</li>
  </ul>
  <p>These two limitations aside, arrow functions could theoretically replace regular functions almost anywhere. What is the right approach using them in practice? Should arrow functions be used e.g.:</p>
  <ul>
  <li>&quot;everywhere they work&quot;, i.e. everywhere a function does not have to be agnostic about the <code>this</code> variable and we are not creating an object.</li>
  <li>only &quot;everywhere they are needed&quot;, i.e. event listeners, timeouts, that need to be bound to a certain scope</li>
  <li>with 'short' functions, but not with 'long' functions</li>
  <li>only with functions that do not contain another arrow function</li>
  </ul>
  <p>I am looking for a guideline to selecting the appropriate function notation in the future version of ECMAScript. The guideline will need to be clear, so that it can be taught to developers in a team, and to be consistent so that it does not require constant refactoring back and forth from one function notation to another.</p>
  <p><sub>The question is directed at people who have thought about code style in the context of the upcoming ECMAScript 6 (Harmony) and who have already worked with the language.</sub></p>