123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <!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>
- /*
- let 和 var 的区别
- 1、let不能重复声明
- 2、let 没有变量提升
- 3、临时失效区 在这个区域内 不允许同名的变量出现
- 4、let具有块级作用域
- */
- // var a = 10;
- // var a = 20;
- // console.log(a)
- // let b = 10;
- // let b = 20;
-
- // let b = 10;
- // function fn(){
- // console.log(b)
- // b = 'abc'
- // }
- // fn()
- // console.log(b)
- // var a = 10;
- // function f1(){
- // console.log(a)
- // var a = '123'
- // }
- // f1()
- // console.log(a)
- // console.log(a)
- // let a = 123
- var a = true
- if(a){
- let x = 100
- }
- console.log(x)
- </script>
- </body>
- </html>
|