someExperience

// 面试题1
var name = 'World';
(function () {
    if (typeof name==='undefined') {
        var name = 'jack';
        console.log('Good bye' + name)
    }else{
        console.log('Hello' + name)
    }

})();
//Good byejack  答对了,变量提升


// 2
var str = 'hi'; 
console.log('Value' + (str==='hi')?'something':'nothing')//something

// 3
var arr = [0,1,2];
arr[10] = 10;//[ 0, 1, 2, , , , , , , , 10 ]
var arr2 = arr.filter(function(x){
    return x===undefined
});
console.log(arr2)//[]

// 4
function showCase(value){
    switch(value){
        case 'A':
            console.log('Case A');
            break;
        case 'B':
            console.log('Case B');
            break;
        case 'C':
            console.log('Case C');
            break;
        case 'D':
            console.log('Case D');
            break;
        default:
            console.log('unkonw')    
    }
}
showCase(new String('A'));//unkonw
console.log(new String('A'))//[String: 'A']
// 5

function isOdd(num){
return num%2 ==1;
}
function isEven(num){
return num%2 == 0;
}
function isSane(num){
return isEven(num) || isOdd(num)
}
var value = [7,4,'13',-9,Infinity];
var mapReruslt = value.map(isSane);
console.log(mapReruslt)//[ true, true, true, false, false ] //我的答案 true, true, false, false, false

// 6
console.log('5'+3);//53
console.log('5'-3)//2

// 7
console.log(Array.prototype)//[]
console.log(Array.isArray(Array.prototype))//true

8
function sidEff(ary){
    ary[0] = ary[2];
}
function bar(a,b,c){
    c = 10;
    sidEff(arguments);
    return a+b+c
}
console.log(bar(1,1,1))//我的答案21结果是对的

function foo(a){
    var a;
    return a;
}
function bar(a){
    var a = 'bye';
    return a;
};
console.log([foo('hello'),bar('hello')])//[ 'hello', 'bye' ]  //我的答案是undefined  bye

var a ={}; b =Object.prototype;
console.log(a.prototype === b,Object.getPrototypeOf(a)===b)//false true  //我的答案true true

 

posted @ 2016-10-27 15:59  overAgain  阅读(234)  评论(0编辑  收藏  举报