块级作用域

{}
if(true){
  let a=12;
}
alert(a);

这种写法会报错a未定义,因为a是在if{}这个会计作用域里面定义的,所以外面是获取不到的



{
  let a=12;

}
alert(a);

同理