es6 arrow function with parameters code example
Example 1: js arrow function
const add = (a, b) => a + b;
const square = num => {
return num * num;
}
const rollDie = () => (
Math.floor(Math.random() * 6) + 1
)
Example 2: es6 arrow function
const multiplyES6 = (x, y) => x * y;
Example 3: arrow func in javascript
const greet = (who) => {
return `Hello, ${who}!`;
};
greet('Eric Cartman');
Example 4: es6 arrow function
var phraseSplitterEs5 = function phraseSplitter(phrase) {
return phrase.split(' ');
};
const phraseSplitterEs6 = phrase => phrase.split(" ");
console.log(phraseSplitterEs6("ES6 Awesomeness"));