第一种:
function add(a,b){
return a+b;
}
res=add(1,1);
console.log(res);
第二种:
let res=function add(a,b){
return a+b;
}
console.log(res(2,2));
扫描二维码关注公众号,回复:
16977971 查看本文章
第三种 是比较特殊的:
function add(a,b){
return a+b;
}(1,2)
console.log(res);
第四种 是立即调用的 函数前加符号: ! ~ 都是立即调用:
(function add(a,b){
return a+b;
}(1,2))