面试题1

Posted ron123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了面试题1相关的知识,希望对你有一定的参考价值。

1、

var ryl = {
    bar: function(){
        return this.baz;
    },
    baz: 1
};

(function(){
    console.log(typeof arguments[0]()); //undefined
})(ryl.bar);

 2、

function test(){
    console.log("out");
}

(function(){
    if(false){
        function test(){  
            console.log("in");
        }
    }
    test();
})();

// 等价于
function test(){
    console.log("out");
}

(function(){
       var test; // 变量提升
    if(false){
        function test(){  
            console.log("in");
        }
    }
    test();
})();

    

 

以上是关于面试题1的主要内容,如果未能解决你的问题,请参考以下文章