zoukankan      html  css  js  c++  java
  • 常见的字符串隐式转换

    32+32          //64

    "32"+32        //"3232"

    "32"-32         //0

    "32"-0          //32    (将字符串转换为数字)

    7-"a"    //NaN

    "a"-"b"    //NaN

    +{}[true]    //NaN

    !{}[true]        //true

    +!{}[true]        // 1

    +[1]      //1

    +[1,2]     //NaN 

    7/0         // Infinity

    !null      // true

    !undefined    //true

    !NaN      //true

    "1.23"==1.23           //true            (尝试string转number)

    0==false                  //true            (尝试boolean转number)

    0==null        //false

    null==undefined         //true

    null==false      //false

    new Object()==new Object()         //true    

    [1,2]==[1,2]                                   //true   

    new String("hi")=="hi"                  //true             (object==number|string尝试对象转为基本类型) 

    全等"==="

    类型不同,返回false;

    类型相同:

        NaN≠NaN

        new Object≠new Object

        null===null

        undefined===undefined

  • 相关阅读:
    SonarQube
    Gerrit
    Jenkins
    Jenkins
    GitLab
    GitLab
    GitLab
    centos7配置国内yum源
    CentOS7 ping: unknown host www.baidu.com
    VirtualBox下安装CentOS7系统
  • 原文地址:https://www.cnblogs.com/lmsblogs/p/5902865.html
Copyright © 2011-2022 走看看