ES 2015

Arrow functions

Arrow functions - example 1

A simple example with one parameter, using template literals to return the result.
let arrowFunction1 = (x) => {
  return `Hello ${x},<br> from the first arrow function`;
}
Or even without the (), as there's only one parameter, x.
let arrowFunction1 = x => {
  return `Hello ${x},<br> from the first arrow function`;
}
Or just on one line.
let arrowFunction1 = x => `Hello ${x},<br> from the first arrow function`;
RESULT: arrowFunction1('John Doe')

Arrow functions - example 2

Using two parameters.
let arrowFunction2 = (x,y) => {
  return x + y;
}
Or even shorter:
let arrowFunction2 = (x,y) => x + y;
RESULT: arrowFunction2(13,34)

Arrow functions - example 3

Without parameters:
let arrowFunction3 = () => "I'm function three...";
RESULT: arrowFunction3()