JS 变量应先声明,再使用
1、未先声明,就使用变量会抛出异常 if(aaaa === undefined) {}
//异常: aaaa is not undefined
2、声明可以在上下文任意位置,但取值是在具体赋值时生效 if(aabc1 === undefined) { console.log("aabc if = ", aabc1) } else { console.log("aab else = ",aabc1); } var aabc1 = 1;
//打印出aabc if = undefined