javascript函数作为变量传递 分类 前端开发 > javascript · 发表于 2015-10-29 14:19:13 js中当函数不加括号时可以把函数当成值传递。 无参数: 123456// 无参函数function foo (){ console.log(1);}var bar = foo; 有参时需要用一个匿名函数: 123456function foo (arg1, arg2) { console.log(1);}var bar = function(arg1, arg2) { foo(arg1, arg2);};