javascript未声明但赋值的变量为全局变量

function test() {
    var a = b = 1;
}
test();

console.log(b);         //1
console.log(window.a);  //undefined
console.log(a);         //报错

你可能感兴趣的:(javascript)