The following line:

var A = function def() {alert();};

Only A() invokes the function. def() does not. Why is it so? Isn't the left side a function delaration?

有帮助吗?

解决方案

In the function expression the function name is primarily used for self-calling. IRL this feature is handy in case of anonymous functions and recursive calls, i.e.

(function def() {
    // ...
    def();
})();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top