Функция стрелки JavaScript с одним аргуменом
let greet = x => console.log(x);
greet('Hello'); // Hello
SAMER SAEID
let greet = x => console.log(x);
greet('Hello'); // Hello
let func = (a) => {} // parentheses optional with one parameter
let func = (a, b, c) => {} // parentheses required with multiple parameters
const power = (base, exponent) => {
let result = 1;
for (let count = 0; count < exponent; count++) {
result *= base;
}
return result;
};
multiplyfunc = (a, b) => { return a * b; }
hello = () => {
return "Hello World!";
}
// Traditional Function Expression
var add = function(a,b){
return a + b;
}
// Arrow Function Expression
var arrowAdd = (a,b) => a + b;