Arrow function in ES6

Arrow functions – also called “fat arrow” functions.
Arrow functions allow us to write the short syntax for function expressions.
Arrow function is not redefining this keyword or execution context

 Click here to learn more about this keyword

// ES5 
var x = function(x, y) { return x * y; } 

// ES6
 const x = (x, y) => x * y;

return keyword required when the statements are in curly brackets.

 const x = (x, y) => { return x * y};
Read also:




Comments