预编译过程

    */
    // 预编译发生在执行之前
    // 1.初始化全局对象
    // Global Object 全局对象
    // 2.全局作用域下 函数声明提升
    /*
      Global Object {}
        function foo: undefined

    // 3.全局作用下 变量声明提升
    /*    
        Global Object {
            function foo: undefined,
                        a: undefined,
                        b: undefined,
                        c: undefined,
        }
    */
    // 4.给提升的函数赋值 function 
    /*    
        Global Object {
            function foo: function,
                        a: undefined,
                        b: undefined,
                        c: undefined,
        }
    */
    // --- Go 预编译结束 ---

    // --- 解析执行 ---
    // 给Global Object 对象下属性 重新赋值的过程

    // var a = '123'; // 执行完毕后go 什么变化?
    /*    
        Global Object {
            function foo: function,
                        a: '123',
                        b: undefined,
                        c: undefined,
        }
    */
    // var b = 'xk';
    /*    
        Global Object {
            function foo: function,
                        a: '123',
                        b: 'xk',
                        c: undefined,
        }
    */
    // var c = function(){}; // 声明变量c 赋值为函数指针
    /*    
        Global Object {
            function foo: function,
                        a: '123',
                        b: 'xk',
                        c: function,
        }
    */
    // ---Go 这段 重新赋值结束

    // --- 函数定义阶段 没执行
    // function foo(a,b){
    // 函数执行前准备
    // 1.初始化Active Object (AO) 对象
    /*
        Active Object{}
    */
    // 2.提升形参
    /*
         Active Object{
             a:undefined
             b:undefined
         }
    */
    // 3.提升函数
    /*
         Active Object{
              a:undefined
              b:undefined
              bar:undefined
          } 
    */
    // 4.提升变量
    /*
          Active Object{
               a:undefined
               b:undefined
               bar:undefined
               lt:undefined
           } 
     */
    // 5.给提升的函数赋值 function
    /*
          Active Object{
               a:undefined
               b:undefined
               bar:function
               lt:undefined
           } 
     */

    // 6.形参实参相统一
    /*
          Active Object{
               a:1
               b:2
               bar:ufunction
               lt:undefined
           } 
     */
    // --- AO预编译结束 ---

    // --- 解析执行 ---
    //     var lt = 'lt';
    //     /*
    //         Active Object{
    //             a:1
    //             b:2
    //             bar:function
    //             lt:'lt'  undedined--->'lt'
    //         }
    //     */
    //     function bar(){}1
    // } // 执行完毕 AO 销毁
    // foo(1,2)

    // var x = 20;
    // var a = {
    //     x: 15,
    //     fn: function () {
    //         var x = 30;
    //         console.log(this);
    //         return function () {
    //             return this.x
    //         }
    //     }
    // }
    // // console.log(a.fn(); // 
    // // a.fn();
    // // function f1() {
    // //     return this.x
    // // }
    // // console.log(k);
    // // (a.fn())();
    // console.log((a.fn())()); // 
    // // console.log(a.fn()());
    // // console.log(a.fn()() == (a.fn())());


    // // function f2(){};
    // // f1()

    // function test() {
    //     console.log(this === global); // true
    // }
    // test() // 
    // console.log(window);

    // const obj = 1

    // function test() {
    //     console.log(this);
    // }
    // const testObj = test.bind(obj);
    // // test(); // 
    // // testObj(); // 
    // testObj();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值