es6 define function code example
Example 1: Arrow Functions
const magic = function() {
return new Date();
};
const magic = () => {
return new Date();
};
const magic = () => new Date();
Example 2: es6 arrow function
var phraseSplitterEs5 = function phraseSplitter(phrase) {
return phrase.split(' ');
};
const phraseSplitterEs6 = phrase => phrase.split(" ");
console.log(phraseSplitterEs6("ES6 Awesomeness"));
Example 3: concise body arrow functions javascript
const plantNeedsWater = day => day === 'Wednesday' ? true : false;