预编译四部曲:

  1. 创建AO对象
  2. 找形参和变量声明,将变量和形参名作为AO的属性名,值为undefined
  3. 将实参值和形参统一
  4. 在函数体里找函数声明,值为其函数体

function test(a, b) {
          console.log(a);//1
          c=0;
          var c;
          a = 3;
          b = 2;
          console.log(b);//2
          function b(){}
          function d(){}
          console.log(b);//2
   }
   test(1);

   // AO{
   //     a:un==>1
   //     b:un==>fun b(){}
   //     c:un==>
   //     d:fun d(){}
   // }

 function test(a, b){
       console.log(a);//fn a(){}
       console.log(b);//un
       var b = 234;
       console.log(b);//234
       a = 123;
       console.log(a);//123
       function a(){}
       var a;
       b= 234;
       var b = function(){}
       console.log(a);//123
       console.log(b);//fn(){}
   }
   test(1);

   // AO{
   //     a:un==>1==>fn a(){}
   //     b:un
   // }

 // GO{
   //         global:100
   // }
   global = 100;
   function fn(){
       console.log(global);//un
       global = 200;
       console.log(global);//200
       var global = 300;
   }
   
       // AO{
       //     global:und
       // }

   fn();
   var global;

 // GO{
   //         a = 100
   // }
   a = 100;
   function demo(e){
          function e(){}
          arguments[0] = 2;
          console.log(e);//2
          // if(a){
                 var b = 123;
                 function c(){}
          // }
          var c;
          a = 10;
          var a;
          console.log(b);//un
          f = 123;
          console.log(c);//un  fn c(){}
          console.log(a);//10
   }
   var a;
   
   // AO{
   //     a:un
   //     b:un
   //     c:un
   //     e:un==>1==>fun e(){}
   // }

   demo(1);
   console.log(a);//100
   console.log(f);//123

 var str = false + 1;
   document.write(str);
   var demo = false ==1;
   document.write(demo);
   if(typeof(a)&&-true + (+undefined) + ""){
       document.write('基础扎实');
   }
   if(11 + "11" * 2 == 33){
       document.write('基础扎实');
   }
   !!" " + !!"" - !!false||document.wirte('你觉得能打印,你就是猪');

 

//后执行打印

function bar(){
       return foo;
       foo = 10;
       function foo(){}
       var foo = 11;
   }
   console.log(bar()); 

 //先执行打印

console.log(bar());
   function bar(){
          foo = 10;
          function foo(){}
          var foo = 11;
       return foo;
   }

 

预编译

// GO{
    //     test:234
    // }
   console.log(test);//整个test(test){函数体}
   function test(test){
       console.log(test);//fn test(){}
       var test = 234;
       console.log(test);//234
       function test(){
       }

   }
   // AO{
   //     test:un==>1==>fn test(){}
   // }
   test(1);
   var test = 234;

预编译 

预编译

 

 

 

 

相关文章: