3_const.html 748 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. /*
  12. const
  13. 1、不能重复声明
  14. 2、没有变量提升
  15. 3、临时失效区
  16. 4、块级作用域
  17. */
  18. // const a = 100;
  19. // console.log(a)
  20. // const a = 100
  21. // a = 200
  22. // console.log(a)
  23. // console.log(a)
  24. // const a = 100
  25. // const a = 100
  26. // function fn(){
  27. // console.log(a)
  28. // const a = 10
  29. // }
  30. // fn()
  31. var a = true
  32. if(a){
  33. const x = 100
  34. }
  35. console.log(x)
  36. </script>
  37. </body>
  38. </html>