Lesson 17. Arrow functions

After reading lesson 17, you will

  • Know how to make your code succinct with arrow functions
  • Know how to maintain context with arrow functions

Arrow functions in JavaScript are directly inspired by the fat arrow functions of CoffeeScript. They behave similarly to CoffeeScript’s by providing a much more succinct way of writing a function expression and also maintaining their context (what this refers to). The syntax isn’t always the same as CoffeeScript’s but they are just as useful and a great addition that makes things like anonymous functions and inline callbacks much more elegant.

Sometimes extraneous syntax can make code much harder for the human mind to parse, because there are several extra pieces to think ...

Get Get Programming with JavaScript Next now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.