The base ES6 - comparison of the two values are equal Object.is ()

Compare two values ​​are equal we can use == or === judge absolutely equal use. They have disadvantages, the former will be automatically converted to data type, which is not equal NaN itself equal to the negative and positive 0 0
+0 == -0 //true
+0 === -0 //true
But these two things are not the same

Another example:
NaN == NaN // false
But they are a thing

In such cases, you can use Object.is () method, two parameters is to compare things, such as:
Object.is (, at) // true
Object.is(+0,-0) //false

In most cases, or may be used to judge whether == === or two values ​​are equal

Guess you like

Origin www.cnblogs.com/fe-cherrydlh/p/11080759.html