In ECMAScript 2015 , also known as ES6 , many new features were introduced. One of the feature which get introduced was “Arrow Functions”.

/********* Traditional way *************/


var func1 = function old(x,y) {

return x+y;


}

/************* New way ***************/

var func2 = (x,y) => {

return x+y;


}

If the function’s body has only the return statement

var func3 = (x,y) => x+y;


var func4 = (x) => x*1;

The Arrow functions can be invoked like normal functions


func1(1,1); // Output 2

func2(1,1); // Output 2


func3(1,1); // Output 2


func4(3); // Output 3