nested arrow functions code example
Example 1: Arrow Functions
const magic = function() {
return new Date();
};
const magic = () => {
return new Date();
};
const magic = () => new Date();
Example 2: pass a variable by reference to arrow function
params => ({foo: bar})
(param1, param2, ...rest) => { statements }
(param1 = defaultValue1, param2, …, paramN = defaultValueN) => {
statements }
var f = ([a, b] = [1, 2], {x: c} = {x: a + b}) => a + b + c;
f();
Example 3: concise body arrow functions javascript
const plantNeedsWater = day => day === 'Wednesday' ? true : false;
Example 4: es6 arrow function
const prices = smartPhones.map(smartPhone => smartPhone.price);
console.log(prices);