The Object.is(value1, value2) method

The Object.is() method determines whether two values are equal or not. It is similar to the === operator but there are some special cases for the Object.is() method. Here is an example that demonstrates special cases:

console.log(Object.is(0, -0));
console.log(0 === -0);
console.log(Object.is(NaN, 0/0));
console.log(NaN === 0/0);
console.log(Object.is(NaN, NaN));
console.log(NaN ===NaN);

The output is as follows:

false
true
true
false
true
false

Here's a handy table you might want to look at for the differences between 0==, ===, and Object.is:

While it might seem intuitive that Object.is can compare if two given objects are same, that is not the case. x = {foo: 1} and y = {foo: 1} are not same for all three operators (==, ===, and Object.is).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.40.28