JavaScript

JavaScript - function syntax between ES5 and ES6


ES5

function foo() {

...
}

foo();



ES6

const foo = () => {

...
}

foo();



ES5_Return

function foo() {

return 'Hello Taiwan';
}


ES6_Return

const foo = () => 'Hello Taiwan';



ES5_Return_Parameters

function foo(a, b) {

return a+b;
}


ES6_Return_Parameters

const foo = (a, b) => a+b;


https://medium.freecodecamp.org/es6-functions-9f61c72b1e86

https://pjchender.blogspot.com/2017/01/es6-arrow-function.html

https://medium.com/@thejasonfile/es5-functions-vs-es6-fat-arrow-functions-864033baa1a