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的改变???
这个问题出现很多次了
https://segmentfault.com/a/11...
https://segmentfault.com/q/10...