zoukankan      html  css  js  c++  java
  • 面试题

    console.log(typeof([]));//object
    console.log(typeof({}));//object
    console.log(typeof(NaN));//number
    console.log(typeof(Null));//undefined
    console.log(typeof(('abcd')*5));//number
    console.log(typeof(('abcd')+5));//string
    console.log(1 && 2);//2
    console.log(1 & 2);//0
    console.log(1 || 2);//1
    console.log(1 | 2);//3
    console.log(NaN==NaN);//false
    console.log(true+1);//2

    window.val=1;
    var json={
    val:10,
    dbl:function(){
    this.val*=2;
    }

    };
    json.dbl();
    var dbl=json.dbl;
    dbl();
    json.dbl.call(window);
    alert(window.val+json.val);

    (function(){
    var val=1;
    var json={
    val:10,
    dbl:function(){
    val*=2;
    }
    };
    json.dbl();
    alert(json.val+val);
    }());


    var test=(function(i){
    return function(){
    alert(i*2);
    }
    }(2));

    test(6);

    function C1(){
    if(name) this.name=name;
    }
    function C2(){
    this.name=name;
    }
    function C3(){
    this.name=name ||'John';
    }
    C1.prototype.name="Tom";
    C2.prototype.name='Tom';
    C3.prototype.name='Tom';
    alert((new C1().name)+(new C2().name)+(new C3().name));

    null == undefined true
    "NaN" == NaN false
    5 == NaN false
    NaN == NaN false
    NaN != NaN true
    false == 0 true
    true == 1 true
    true == 2 false
    undefined == 0 false
    null == 0 false
    "5" == 5 true

    typeof([]) object
    typeof({}) object
    typeof(null) object
    typeof(undefined) undefined
    typeof(NaN) number

    typeof(("abcd")*5) number
    typeof(("abcd")+5) string

  • 相关阅读:
    游戏 猜拳游戏
    python的变量 以及操作系统
    python的异常处理
    python 三元运算
    python random 的用法
    python基础
    Round #417 A. Sagheer and Crossroads(Div.2)
    Round #416 B. Vladik and Complicated Book(Div.2)
    Round #416 A. Vladik and Courtesy(Div.2)
    Educational Round 26 D. Round Subset
  • 原文地址:https://www.cnblogs.com/xiaotaiyang/p/4172072.html
Copyright © 2011-2022 走看看