function foo(){
console.log('foo1');
}
foo();
function foo(){
console.log('foo2');
}
foo();
看看下面两段代码的执行结果:
var scope = "global scope";
function checkscope() {
var scope = "local scope";
function f() {
return scope;
}
return f();
}
checkscope();
var scope = "global scope";
function checkscope() {
var scope = "local scope";
function f() {
return scope;
}
return f;
}
checkscope()();
结果都为:local scope