// 将匿名函数赋值给 myFunc
const myFunc = function(param1, param2, ...) {
// Statements using param1, param2, ...
};
// 调用匿名函数
// param1 value is set to arg1, param2 to arg2, ...
myFunc(arg1, arg2, ...);
另一种方法
const hello = (name) => {
const message = `Hello, ${name}!`;
return message;
};
console.log(hello("William")); // "Hello, William!"