ECMAScript6 new value-added comparison function Object. is, ecmascript6
Before that, we use the equal sign "=" or equal sign "=" to compare values, and the third sign is more strict. If the two types are different, false is returned immediately.
In addition, there is only one value that is not equal to itself. It is NaN
Now ES6 adds an Object. is, which makes the comparison operation more chaotic. In most cases, Object. is equivalent to "=", as shown below:
1 = 1 // trueObject. is (1, 1) // true 'A' = 'A' // trueObject. is ('A', 'A') // true = true // trueObject. is (true, true) // true null === null // trueObject. is (null, null) // true undefined === undefined // trueObject. is (undefined, undefined) // true
But for NaN, 0, + 0,-0, it is different from "="
NaN = NaN // falseObject. is (NaN, NaN) // true 0 ===-0 // trueObject. is (0,-0) // false-0 = + 0 // trueObject. is (-0, + 0) // false
The above is all the content of this article. I hope you will like it.