lambda javascript code example
Example 1: js lambda
function (a, b){
return a + b + 100;
}
(a, b) => a + b + 100;
let a = 4;
let b = 2;
function (){
return a + b + 100;
}
let a = 4;
let b = 2;
() => a + b + 100;
Example 2: Arrow Functions
const magic = function() {
return new Date();
};
const magic = () => {
return new Date();
};
const magic = () => new Date();
Example 3: 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");
};