博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JavaScript相等运算符
阅读量:2502 次
发布时间:2019-05-11

本文共 1078 字,大约阅读时间需要 3 分钟。

Those operators accept two values and return a boolean:

这些运算符接受两个值并返回一个布尔值:

  • == checks for equality

    ==检查是否相等

  • != checks for inequality

    !=检查不平等

  • === checks for strict equality

    ===检查严格相等

  • !== checks for strict inequality

    !==检查严格的不平等

Let’s talk what we mean for strict. Without the strict check, the second operand is converted to the type of the first before making the comparison. Strict prevents this.

让我们说说“ 严格”的含义。 如果没有严格检查,则在进行比较之前,第二个操作数将转换为第一个操作数的类型。 严格防止这种情况。

Examples:

例子:

const a = truea == true //truea === true //true1 == 1 //true1 == '1' //true1 === 1 //true1 === '1' //false

You cannot check objects for equality: two objects are never equal to each other. The only case when a check might be true is if two variables reference the same object.

您无法检查对象是否相等:两个对象永远不会彼此相等。 检查可能为true的唯一情况是两个变量是否引用同一个对象。

Some peculiarities to be aware: NaN is always different from NaN.

需要注意的一些特殊之处: NaN始终不同于NaN

NaN == NaN //false

null and undefined values are equal if compared in non-strict mode:

如果在非严格模式下进行比较,则nullundefined值相等:

null == undefined //truenull === undefined //false

翻译自:

转载地址:http://hxqgb.baihongyu.com/

你可能感兴趣的文章
netfilter/iptables全攻略
查看>>
Overlay之VXLAN架构
查看>>
Eclipse : An error occurred while filtering resources(Maven错误提示)
查看>>
在eclipse上用tomcat部署项目404解决方案
查看>>
web.xml 配置中classpath: 与classpath*:的区别
查看>>
suse如何修改ssh端口为2222?
查看>>
详细理解“>/dev/null 2>&1”
查看>>
suse如何创建定时任务?
查看>>
suse搭建ftp服务器方法
查看>>
centos虚拟机设置共享文件夹并通过我的电脑访问[增加smbd端口修改]
查看>>
文件拷贝(IFileOperation::CopyItem)
查看>>
MapReduce的 Speculative Execution机制
查看>>
大数据学习之路------借助HDP SANDBOX开始学习
查看>>
Hadoop基础学习:基于Hortonworks HDP
查看>>
为什么linux安装程序 都要放到/usr/local目录下
查看>>
Hive安装前扫盲之Derby和Metastore
查看>>
永久修改PATH环境变量的几种办法
查看>>
大数据学习之HDP SANDBOX开始学习
查看>>
Hive Beeline使用
查看>>
Centos6安装图形界面(hdp不需要,hdp直接从github上下载数据即可)
查看>>