zoukankan      html  css  js  c++  java
  • JavaScript中==和===区别

    在我们的日常编码中对于===是不常用的,但是它很重要

    ===:表示绝对相等(严格)

    !==:表示不绝对相等

    ==:表示相等(不严格)

    !=:表示不相等

    看一下列子:

    null==undefined  结果是为true

    null===undefined 结果是为false

    0==false,0=='',''==false 结果都是为true

    0===false,0==='',''===false 结果都是为false

    反之:!=和!==结果和上面相反

    测试代码:

    alert("null==0 is "+(null==0)+" "+"null==undefined is "+(null==undefined)+" "+"null=='' is "+(''==null)+" "+"null==false is "+(null==false)+" "+"0=='' is "+(0=='')+" "+"0==false is "+(0==false)+" "+"0==undefined is "+(0==undefined)+" "+"''==false is "+(''==false)+" "+"''==undefined is "+(''==undefined)+" "+"false==undefined is "+(false==undefined));

    alert("null===0 is "+(null===0)+" "+"null===undefined is "+(null===undefined)+" "+"null==='' is "+(''===null)+" "+"null===false is "+(null===false)+" "+"0==='' is "+(0==='')+" "+"0===false is "+(0===false)+" "+"0===undefined is "+(0===undefined)+" "+"''===false is "+(''===false)+" "+"''===undefined is "+(''===undefined)+" "+"false===undefined is "+(false===undefined));

  • 相关阅读:
    App.domain http->https
    js 点赞数 处理
    js插入拼接链接 --包含可变字段
    MYSQL修改表操作
    PHP上传文件类 代码练习
    PHP上传文件代码练习2 (重复文章)
    自制山寨百度一下
    PHP多文件上传代码练习
    修改PHP上传文件的大小限制
    三维数组变两位数组
  • 原文地址:https://www.cnblogs.com/javatech/p/3653802.html
Copyright © 2011-2022 走看看