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

  • 相关阅读:
    B树与B+详解
    SQLite占用资源少原因
    iOS SQLite详解
    YTKNetwork网络封装
    YTKNetwork源码详解
    AFNetworking封装-项目使用
    iOS网络请求-AFNetworking源码解析
    PHP 不使用第三个变量实现交换两个变量的值
    PHP public private protected 三种修饰符的区别
    PHP 汉字转拼音
  • 原文地址:https://www.cnblogs.com/lmsblogs/p/5902865.html
Copyright © 2011-2022 走看看