let声明变量
// var 声明的变量没有局部作用域 // let 声明的变量 有局部作用域 { var a = 1; let b = 2; } console.log(a) console.log(b) //b is not defined // var 可以声明多次 // let 只能声明一次 var m = 1; var m = 2; let n = 10; let n = 20; //'n' has already been declared console.log(m) console.log(n)