书籍《学习JavaScript》将匿名函数定义如下...
这是JavaScript中“匿名函数”的正确定义吗?如果不是,什么是匿名函数,匿名函数和函数字面量之间有什么区别?Functions are objects. As such, you can create them - just like a
String
orArray
or other type - by using a constructor and assigning the function to a variable. In the following code, a new function is created using theFunction
constructor, with the function body and argument passed in as arguments:var sayHi = new Function("toWhom", "alert('Hi' + toWhom);");
This type of function is often referred to as an anonymous function because the function itself isn't directly declared or named.
FunctionExpression
,例如:var fn = function(){..}
与var fn = function fn(){...}
的区别。 - Sean Kinsey