Learning JavaScript ES6: Part 4: Arrow Functions

Learning JavaScript ES6

JavaScript ES6 (ECMAScript 6) is a newer specification for JavaScript introduced in 2015 and adopted by most browsers starting in mid-2016. It added new syntax and a greater ability to use object-oriented programming in JavaScript.

Arrow Functions

In previous versions of JavaScript, anonymous functions were often used in situations where a quick calculation or the use of a function used to move through some organized data might be needed.

Using Arrow Functions

To help in these common situations, ES6 introduced arrow functions. These are a reduced syntax versions of anonymous functions that are written using the arrow, =>.

In most cases, arrow functions can replace anonymous function usage with the shorthand syntax. Even when dealing with multiple parameters, an open and close parenthesis can enclose the data passed to the arrow function.

Play with the example on Repl.it!