面试题巩固

  1、typeof null --object 语言bug,null instanceof Object false

  2、不要代码块迷惑

var name = 'world';
(function(){
   //函数声明提升
   if(typeof name === 'undefined'){
     var name = 'jack';
     console.log("Goodbye"+name); 
   }      
   else{
       console.log("Hello"+name)
    }
})();

3、var ary = [0,1,2];

    ary[10] = 10;

   ary.filter(function(x){return x===undefined})//ES5新方法,对数组中每一项调用函数体,返回该函数执行后的布尔值为true的项所组成的数组。所以返回空数组

4、test的调用和匿名函数内部没有关系,所以返回window

var Foo = {};
Foo.method = function(){
    function test(){
        console.log(this);
    }
    test();
}
Foo.method();
原文地址:https://www.cnblogs.com/wgdong/p/5951305.html