Arrow function easier
1 - normal function
let execute = function(n) {
return n*n;
}
let x = execute(5)
console.log(x)
// Output:
// 25
2 - arrow
let execute = (n) => {
return n * n;
};
let x = execute(5);
console.log(x);
3 - arrow without return
- If arrow function body has one
statementthen,{}not needed
let execute = (n) => n * n;
let x = execute(5);
console.log(x);