/**********seperate line************/
var a = 10;
function test() {
a = 100;
console.log(a);
console.log(this.a);
var a;
console.log(a);
}
test();
VM3854:4 100
VM3854:5 10
VM3854:7 100
/**********seperate line************/
var a = 100;
function test(){
console.log(a);
var a = 10;
console.log(a);
}
test();
VM3896:3 undefined
VM3896:5 10
/**********seperate line************/
var a = 100;
function test(){
console.log(a);
a = 10; //去掉了var 就变成定义了全局变量了
console.log(a);
}
test();
console.log(a);
VM2216:4 100
VM2216:6 10
VM2216:9 10
时间: 2024-10-16 04:10:00