预编译

    // var a = 10; ---> window.a = 10;

    /*
    预编译:
    1.创建AO对象

    2.找形参和变量声明,将变量和形参名作为AO属性名,值为undefined

    3.将实参和形参统一

    4.在函数体里面找函数声明,值赋予函数体
    */

    /*
    window的预编译
    window === GO
    1.生成一个GO对象 Global Object

    2.找形参和变量声明,将变量和形参名作为AO属性名,值为undefined

    3.在函数体里面找函数声明,值赋予函数体

    */
    //例题1:

    /*预编译
    1小时--> 1小时7分结束*/
    // function fn(a) {
    //     console.log(a);
    //     //a = function a () {}

    //     var a = 123;           
    //     console.log(a);
    //     //a = 123

    //     function a() {};
    //     console.log(a);
    //     //a = 123

    //     var b = function () {};          
    //     console.log(b);
    //     //b = function () {}
        
    //     function d() {};
    //     console.log(d);
    //     //d = funxtion d() {}
    // }
    // fn(1);  


    //例题2:[1:08:21 --> 1:11:26]
    // function test(a, b) {
    //     document.write(a);
    //     c = 0;
    //     var c;
    //     a = 3;
    //     b = 2;
    //     document.write(b);
    //     function b() {};
    //     function d() {};
    //     document.write(b);
    // }
    // test(1);
   
    
    //例题3:[]
    // function test(a, b) {
    //     console.log(a);  
    //     console.log(b);   
    //     var b = 234;
    //     console.log(b);   
    //     a = 123;
    //     console.log(a);     
    //     function a () {};
    //     var a;
    //     b = 234;
    //     var b = function () {};
    //     console.log(a);     
    //     console.log(b);
    // }
    // test();


    /*例题4
    //时间 1:21:20-->1:22:30
    暗示全局变量impiy global
    function test () {
        var a = b = 123;
        console.log(window.b)
        //b = 123;

        console.log(window.a)
        //undefined

    }
    test()      
    */
   
//例题5
//时间1:24:01-->1:26:40 
//    console.log(test);
//    test =  function test(test) {
//               console.log(test);
//               var test = 234;
//               console.log(test);
//               function test() {}
//    };
//    function test(test) {
//        console.log(test);
//        test = function test() {};
//        var test = 234;
//        console.log(test);
//        function test() {}
//    }
//    test(1)
//    var test = 123;
                                                                                           


//例题6
//时间1:30:08 -->1:32:11
// global = 100;
// function fn() {
//     console.log(global);
//     
//     global = 200;
//     console.log(global);
//     
//     var global = 300;
// }
// fn();
// var global;



//例题7
//时间1:33:44-->1:38:37
// function test () {
//     console.log(b);
//     if(a) {
//         var b = 100;
//     }
//     console.log(b)
//     c = 234;
//     console.log(c);
// }

// var a;
// test(); 
// a = 10;
// console.log(c);




//例题1 [00:53 -->]
// function bar() {
//     return foo;
//     foo = 10;
//     function foo() {
//         //body...
//     }
//     var foo = 11;
// }

// console.log(bar());


// //例题2
// console.log(bar());
// function bar() {
//     foo = 10;
//     function foo() {
//         //body...
//     }
//     var foo = 11;
//     return foo;
// }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值