zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    C++ 扩展 Op
    Python 扩展 Op
    VS Code 调试 OneFlow
    运行时数据获取
    OFRecord 图片文件制数据集
    OFRecord 数据集加载
    OFRecord 数据格式
    OneFlow 并行特色
    Consistent 与 Mirrored 视角
    作业函数的定义与调用
  • 原文地址:https://www.cnblogs.com/mr-pz/p/6004297.html
Copyright © 2011-2022 走看看