{var aOfVar=5}
console.log(aOfVar)//5{let aOfLet=6}
console.log(aOfLet)// aOfLet is not defined{const aOfConst=7}
console.log(aOfConst)// aOfLet is not defined
2.4 重复声明
var 允许重复生命两个同名变量
let和const不可以
var aOfVar=5var aOfVar=55
console.log(aOfVar)//55let aOfLet=6.let aOfLet=66// Identifier 'aOfLet' has already been declaredconst aOfConst=7const aOfConst=77// Identifier 'aOfLet' has already been declared
2.5 变量值修改
var和let的变量值可以修改
const变量的值不可以修改
var aOfVar=5
aOfVar=55
console.log(aOfVar)//55let aOfLet=6.
aOfLet=66
console.log(aOfLet)//66const aOfConst=7
aOfConst=77// Assignment to constant variable.
2.6 window绑定
var定义的变量会被绑定在window对象上
而let和const不会
var aOfVar=5
console.log(window.aOfVar)//55let aOfLet=6.
console.log(window.aOfLet)//undefinedconst aOfConst=7
console.log(window.aOfConst)//undefined