문제

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