首页 > 代码库 > ES6

ES6

1.let命令:

相当于var,声明的变量只在所在的代码块内有效,eg:

{

 let a = 1;

var b =2;

console.log(a)  //1

}

console.log(a) //not defined

console.log(b) //2

let变量在域解析的时候不好被提升,eg:

console.log(a)  //undefined

var a = 1;

 

console.log(b)  //not defined报错

let b = 2;

 

let变量只能

ES6