javascript types of arrow functions 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: Arrow Functions
const magic = function() {
return new Date();
};
const magic = () => {
return new Date();
};
const magic = () => new Date();
Example 3: arrow func in javascript
const greet = (who) => {
return `Hello, ${who}!`;
};
greet('Eric Cartman');
Example 4: javascript arrow function
let errow = () => {
};
Or
let errow = ('paramiter') => {
}
Example 5: arrow function javascript
const power = (base, exponent) => {
let result = 1;
for (let count = 0; count < exponent; count++) {
result *= base;
}
return result;
};
const square1 = (x) => { return x * x; };
const square2 = x => x * x;
const horn = () => {
console.log("Toot");
};