In a previous article, we've looked at how to use JavaScript anonymous functions - they are nameless functions that are used extensively in methods that take function parameters:

let myArray = [1, 4, 42, 11, 79];
let doubleArray = myArray.map(function (item) {
  return item * 2;
});
console.log(doubleArray); // [2, 8, 84, 22, 158]

ES6 introduced a new syntax for functions - our example can be written more concise as:

let myArray = [1, 4, 42, 11, 79];
let doubleArray = myArray.map( item => {
  return item * 2;
});
console.log(doubleArray); // [2, 8, 84, 22, 158]

DOM elements management

An area that benefited massively from this new syntax was DOM elements manipulation and actions. For example, triggering actions when a button is clicked is now as simple as:

let signupButton = document.getElementById("signup");
signupButton.click(event => {
  console.log(`New signup: ${signupButton}`);
});

Next Steps