Why do I get the value “result” for this closure?

后端 未结 3 1229
迷失自我
迷失自我 2020-12-20 02:42

Let\'s say I have this code (fiddle) intended to memoize modules:

var chat = {
 // Create this closure to contain the cached modules
 module: function() {
           


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-20 03:08

    console.log('in module:', name);
    

    You are logging name before you ever declare it. So it's using window.name instead.

提交回复
热议问题