函数提升后,执行到函数所在位置时做了些什么?

    console.log(window.a, a);//undefined undefined

    var a;
    console.log(window.a, a);//undefined undefined

    a = 10
    if (true) {
      console.log(window.a, a);//10 ƒ a() { }

      a = 20
      console.log(window.a, a);//10 20

      function a() { }
        //注意这里window.a = 20
      console.log(window.a, a);//20 20
      a = 30

      console.log(window.a, a);//20 30

    }
    console.log(window.a, a);//20 20

这里是发生了什么造成了window.a的改变???

阅读 2.3k
2 个回答
推荐问题
宣传栏