<h3>es6变量声明与传统声明方式区别</h3>
<p>var 声明变量没有局部作用域</p>
<p>let 声明的变量,存在局部作用域</p>
<p>var 可以声明多次</p>
<p>let 只能声明一次</p>
<p>const声明常亮(只读变量)</p>
<p>声明之后不允许改变</p>
<p>声明必须初始化,否则报错</p>
<script>
{
var a=0
let b=1
}
console.log(a); //输出0
//console.log(b); //b is not defined 因在作用域外访问变量,所以报错未定义
var m=1
var m=2
let n=3
//let n=4
console.log(m);
//console.log(n); //Identifier 'n' has already been declared
const PI = 3.1415926
PI = 3 //Assignment to constant variable
const my_age; //Missing initializer in const declaration
</script>