开发者

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

开发者 https://www.devze.com 2023-02-28 14:59 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Javascript: var functionNam开发者_运维百科e = function() {} vs function functionName() {}
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

精彩评论

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

关注公众号