js预解析练习
分析下面两段代码
console.log(num)//undefined
var num = 10
f()//可以执行
//f2()不可以执行
console.log(f)//function
console.log(f2)//undefined
function f(){
console.log(num)//undefined
var num = 20
console.log(num)//20
}
console.log(num)//10
var f2 = function(){
console.log('我是f2')
}
f2()//可以执行
console.log(f2)//function
f1();//输出9,9,9
console.log(c);//9
console.log(b);//9
console.log(a);//报错
function f1() {
var a = b = c = 9;//注意b,c是全局变量
console.log(a);
console.log(b);
console.log(c);
}