0
点赞
收藏
分享

微信扫一扫

JavaScript:创建匿名函数

infgrad 2022-01-17 阅读 46
// 将匿名函数赋值给 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!"
举报

相关推荐

0 条评论