1. Home
  2. Javascript
  3. Arrow function evolution

Step by step explanation of the ES6 arrow function syntax.

#javascript#es6
// 1. We start here with the standard function
function(a + b){ 
    return a + b;
}

// 2. Drop the "function" and insert the "=>" after the arguments
(a, b) => { 
    return a + b
};

// 3. Move the function body to a single line. One line arrow functions will automatically return the output. This allows you to drop the "return", curly brackets and semicolon.
(a, b) => a + b
copy
Full Javascript cheatsheet