预编译

164 阅读1分钟
function fn(a,c){
            console.log(a) //f a(){}
            var a = 123
            console.log(a) //123
            console.log(c) //f c(){}
            function a(){}
            if(false){
                var d=678
            }
            console.log(d)//undefined
            console.log(b)//undefined
            var b =function() {}
            console.log(b)//f(){}
            function c(){}
            console.log(c)//f c(){}
        }
        fn(1,2)
        //预编译
        //作用域的创建阶段 预编译阶段
        //预编译的时候做了哪些事情
        //js的变量对象 AO对象 供js引擎自己去访问的
        //1 创建了ao对象 2 找形参和变量的声明 作为ao对象的属性名 值为undefined 3 实参和形参相统一 4找函数声明 会覆盖变量的声明
        AO:{
        a:undefined 1 function a(){}
        c:undefined 2 function c(){}
        d:undefined
        b:undefined
        }