This article mainly introduces the new value-added ECMAScript6 comparison function Object. for more information about is, if you need it, please refer to the following. Before that, we should use the equal sign "=" or equal sign "=", and the third digit 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.