2

var a = 1;
(function a(){
    console.log('0:', b)
    console.log('1:', a)
    a = 100
    var b = 2
    console.log('2:', a)
    console.log('3:', b)
})();
console.log('4:', a)

How to understand the change process of 'a' in the function 'a'. Where is the value 100. For normal, pre-analysis and execution should like this:

var any = 1

function any(){}

pre-analysis process:

  1. GLOBAL { any: undefined }
  2. GLOBAL { any: function any(){} }

execution process:

  1. GLOBAL { any: 1 }

But you can't understand the 'a' above in this way. Could you please help me?

ludy
  • 29
  • 3

0 Answers0