Javascript named function as an expression

后端 未结 1 1579
梦毁少年i
梦毁少年i 2020-12-11 11:41

Javascript Code

var d = function c() { console.log(c); };
d(); // function c() { console.log(c); }; 
c(); // Reference Error

I understand t

相关标签:
1条回答
  • 2020-12-11 11:59

    Yes. A named function expression produces a variable corresponding to the function name within the scope of that function only.

    Here's an excellent but lengthy article on the subject: http://kangax.github.com/nfe/

    See also the relevant section of the ECMAScript 5 spec. It has a specific note about this.

    0 讨论(0)
提交回复
热议问题