amm*_*com 0 javascript function local-variables
我正在Google Chrome上对此进行测试:
function test(){
d = 2;
}
function test2(){
test();
document.write(d);
}
test2();
Run Code Online (Sandbox Code Playgroud)
函数中的变量d test应该是本地的,所以我无法在函数中访问它test2,有人可以解释为什么这有效吗?
编辑:
这不是重复的,因为我在原始问题的正确答案中找不到任何地方使用不带var的变量使其成为全局变量,它被隐含地称为"隐式全局变量的恐怖"