- var定义的变量可以修改,如果不初始化会输出undefined,不会报错。
var i ;
console.log(i) //undefined;
i = 3;
console.log(i) //3
var i = 2;
console.log(i) //2
2.let
console.log(i) //ReferenceError
let i;
console.log(i)
var i ;
console.log(i) //undefined;
i = 3;
console.log(i) //3
var i = 2;
console.log(i) //2
2.let
console.log(i) //ReferenceError
let i;
console.log(i)