一、let的三大特性之
1-1:不存在变量提升
image.pngconsole.log(a);
var a = 100;
console.log(a);
console.log(b);
let b = 200;
console.log(b);
image.png
1-2:不能重复声明
image.pnglet b = 200;
let b = 300;
console.log(b);
image.png
1-3:块级作用域,变量只在代码块内有效
image.pngfunction func(){
let n =5;
if(true){
let n = 10;
}
console.log(n);
}
func();
image.png
网友评论