zoukankan      html  css  js  c++  java
  • interview experience

    [] == ![];
    true
    
      [] == !Boolean([]); 逻辑运算需进行数据类型转换
      [] == !true 0 NaN '' null undefined 在boolean中会变成false 其他为true
      [] == false;  
      [] == 0; 如果其中一项为bool值,另外一项不是,则将其转换成数字
      toPrimitive([]) == 0; 如果一项为对象,另一项为数字或字符串,则尝试将对象转换成primitiveValue原始值
      [].valueOf() == 0; 首先尝试调用 valueOf 得到自身 仍然是对象类型
      [] == 0;  
      [].toString() == 0; 再尝试调用 toString
      '' == 0; Array.toString返回一个字符串,使用逗号连接数组中所有元素
      0 == 0 字符串和数值进行比较时,将字符串转换成数值
      0 === 0 两边数据类型一致时,执行严格等运算
        true   得到结果true

    var a = function( k ) { return false; }; a() && [] == ![];
    false	
    

    var k = true; var a = function( k ){ var k = k && true; return k; }; a() && [] == ![];
    undefined
    

    var k = true; var a = function( k ){ var k = k && true; return k; }; a() && [] == ![];
    a=function(){return k};
    

    var arr = [ 1, 2 ]; arr.b = "123"; arr.toString();
    '1,2'
    

    var o = { a : 2, b : function(){ this.a = 3; (function(){ alert( this.a ); // 输出==> this.a = 4; })(); alert( this.a ); // 输出==> return { d : o.a + 3 }; } }; o.b(); o.b.d;

    alert undefined, alert 3, o.b.d undefined

    var i = 1, j = m = 0; function a ( k ){ return k = k + 1; } j = a( i ); function a ( k ){ return k = k + 3; } m = a ( i ); j m

    j 4 m 4

    alert( typeof a); function a(){ alert( "a.function" ); } var a = "a.string"; alert( a );

    alert function alert a.string

    var o = { a : function(){ alert ( this.c ); }, c : " Hunteron " }; ( f = o.a )();

    alert undefined
  • 相关阅读:
    Codeforces Round #632 (Div. 2)
    Codeforces Round #630 (Div. 2)
    多项式全家桶
    Educational Codeforces Round 84 (Rated for Div. 2)
    【cf1186E】E. Vus the Cossack and a Field(找规律+递归)
    [CF847B] Preparing for Merge Sort
    [CF858D] Polycarp's phone book
    [CF911D] Inversion Counting
    [CF938C] Constructing Tests
    [CF960C] Subsequence Counting
  • 原文地址:https://www.cnblogs.com/social/p/4325732.html
Copyright © 2011-2022 走看看