预编译

 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         function fn(a,c){
12             console.log(a) // function a() {}
13             var a = 123
14             console.log(a) // 123
15             console.log(c) // function c() {}
16             function a() {}
17             if (flase){
18                 var d = 456
19             }
20             console.log(d) // undefined
21             console.log(b) // undefined
22             var b = function () {}
23             console.log(b) // function () {}
24             function c() {}
25             console.log(c) // function () {}
26         }
27         fn(1,2)
28 
29         /**预编译
30          *
31          * 1.作用域的创建阶段,预编译的阶段
32          * 2.预编译的时候做了哪些事
33          * 3.js的变量对象 AO对象 供js引擎自己去访问的
34          * 4. 创建ao对象 找实参和申明的变量作为ao对象的属性名,值为undefined 实参和形参相统一 会覆盖变量的申明
35          * 5.js逐行执行
36         */
37 
38         // AO:{
39         //     a:undefined 1 function a() {} 同名覆盖变量申明
40         //     c:undefined 2 function c() {} 同名覆盖变量申明
41         //     b:undefined
42         //     d:undefined
43         //}
44 
45 
46 
47     </script>
48 </body>
49 </html>

 

posted @ 2021-10-27 14:57  TM_cc  阅读(32)  评论(0)    收藏  举报