(function(){ var A = 20; function canReadA(){ console.log(A); } function cannotReadA(){ if(false){ var A = 10; } console.log(A); } canReadA(); cannotReadA();}());
有什么办法能够在cannotReadA()中访问到A=20的那个变量?除了换一个变量名,或者声明一个外部的命名空间,还有什么方法能够直接做到?比如能不能在当前作用函数域中把这个变量的存在取消掉?
收到一只叮咚
相关分类