开发者

What is the difference between x = function(a, b, c){} and function x(a, b, c){}? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Javascript: var functionNam开发者_运维百科e = function() {} vs function functionName() {}

Is there any difference between these two ways of declaring a function?


They are both anonymous functions, only one is assigned to a variable named x.

I think you may be trying to refer to what is known as function expressions and function declarations.


x = function(a, b, c){} assigns the function to the alias x so you would execute it using x(a, b, c). The second is an anonymous function that would not be accessible after the place that it was declared as it is not assigned to anything.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜