In Javascript, what is the motivation or advantage of using var foo = function foo(i) { … }?
- 阅读更多 关于 In Javascript, what is the motivation or advantage of using var foo = function foo(i) { … }?
问题 I see that in the answer of In Javascript, why write "var QueryStringToHash = function QueryStringToHash (query) { ... }"? which is doing something like var foo = function foo(param) { ... } in that particular case, why do that instead of just using function foo(param) { ... } ? What is the advantage or motivation of doing that? 回答1: In shortly, if you take the following code, the first example creates a function, named foo , the second example creates an anonymous function and assign it to