var/let/const
<script>
function show(){
if(1==1){
var name = "szw"; //函数作用域=Python
}
consolo.log(name);
}
show();
</script>
<script>
if(1==1){
let age = 19; // 块级作用域
}
console.log(age);
</script>
<script>
if(1==1){
const age = 19; // 块级作用域 + 常量(ref)
}
console.log(age);
</script>
<script>
const info = {id:1,value:18}; // 块级作用域 + 常量(ref)
info.value = 999;
</script>
标签:块级,const,log,作用域,age,变量,常量
From: https://www.cnblogs.com/sherwin1995/p/16889564.html