1_let.html 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. let 和 var 的区别
  13. 1、let不能重复声明
  14. 2、let 没有变量提升
  15. 3、临时失效区 在这个区域内 不允许同名的变量出现
  16. 4、let具有块级作用域
  17. */
  18. let c = 10
  19. c = 20
  20. console.log(c)
  21. // var a = 10;
  22. // var a = 20;
  23. // console.log(a)
  24. // let b = 10;
  25. // let b = 20;
  26. // let b = 10;
  27. // function fn(){
  28. // console.log(b)
  29. // b = 'abc'
  30. // }
  31. // fn()
  32. // console.log(b)
  33. // var a = 10;
  34. // function f1(){
  35. // console.log(a)
  36. // var a = '123'
  37. // }
  38. // f1()
  39. // console.log(a)
  40. // console.log(a)
  41. // let a = 123
  42. var a = true
  43. if(a){
  44. let x = 100
  45. }
  46. console.log(x)
  47. </script>
  48. </body>
  49. </html>