本文共 820 字,大约阅读时间需要 2 分钟。
object is
This method was introduced in ES2015. It aims to help comparing values.
ES2015中引入了此方法。 它旨在帮助比较价值。
Usage:
用法:
Object.is(a, b)
The result is always false
unless:
结果始终为false
除非:
a
and b
are the same exact object
a
和b
是相同的精确对象
a
and b
are equal strings (strings are equal when composed by the same characters, in the same order)
a
和b
是相等的字符串(当由相同的字符以相同的顺序组成时,字符串是相等的)
a
and b
are equal numbers (numbers are equal when their value is equal)
a
和b
是相等的数字(数值相等时数字相等)
a
and b
are both undefined
, both null
, both NaN
, both true
or both false
a
和b
都undefined
,都为null
,都为NaN
,都为true
或均为false
0
and -0
are different values in JavaScript, so pay attention in this special case (convert all to +0
using the +
unary operator before comparing, for example).
0
和-0
是JavaScript中的不同值,因此请注意这种特殊情况(例如,在进行比较之前,使用+
一元运算符将所有值转换为+0
)。
翻译自:
object is
转载地址:http://etqgb.baihongyu.com/