| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | <!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta http-equiv="X-UA-Compatible" content="IE=edge">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>Document</title></head><body>  <script>    /*     const 和 var的区别    1.const 不能重复赋值    2.const 不能重复声明    3.const 没有变量提升    4.const 具有块级作用域    5.const 临时失效区    */    // const a = 100    // a = 200    // console.log(a)    // const a = 100    // const a = 200    // console.log(a)    // console.log(a)    // const a = 100    // const a = 100    // function fn(){    //   a = 10    //   console.log(a)    // }    // fn()    // var a = true    // if(a){    //   const x = 100    // }    // console.log(x)    var a = true    if(a){      var b = 10      let x = 100    }    b = 30    x = 10    const c = 200    function fn(){      console.log(b)      // console.log(h)      // console.log(xx)      let xx = 30      var b = 300      const x = 30      console.log(x)      console.log(c)    }    fn()    console.log(a,b,x,c)    // undefined 报错  30 200   true,30,报错,200    // undefined 报错  10 200   true,30,报错,200    // undefined 报错  30 200   true,30,10,200    // undefined 报错  30 200   true,300,报错,200  </script></body></html>
 |