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
  • 相关阅读:
    业务领域建模Domain Modeling
    用例建模Use Case Modeling
    分析一套源代码的代码规范和风格并讨论如何改进优化代码
    结合工程实践选题调研分析同类软件产品
    如何提高程序员的键盘使用效率?
    CSS水平布局
    CSS文档流
    CSS盒子模型
    CSS单位
    CSS选择器的权重
  • 原文地址:https://www.cnblogs.com/mr-pz/p/6004297.html
Copyright © 2011-2022 走看看