Before Object.is appears, we use the two equal sign "==" or the three equal sign "===" to compare the values. The three equal sign is more stringent. If the two parties compare different types, they will immediately return false.
In addition, there is only one value that is not equal to itself, it is NaN
Now ES6 has added another Object.is to make the world of comparative operations even more chaotic.
In most cases, Object.is is equivalent to "===", as follows
1 === 1 // trueObject.is(1, 1) // true 'a' === 'a' // trueObject.is('a', 'a') // true true === true // trueObject.is(true, true) // true null === null // trueObject.is(null, null) // true undefined === undefined // trueObject.is(undefined, undefined) // trueBut 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 about the Javascript ES6 new value comparison function Object.is. I hope it will be helpful to everyone's study and work.