DEV Community

Kenneth Lum
Kenneth Lum

Posted on • Edited on

6 1

How does JavaScript's Object.is() work?

Sometimes you see of frameworks like ReactJS uses Object.is(), and how can you think of it?

It really is just the same as === except two cases:

> 0 === -0
true

> Object.is(0, -0)
false

> NaN === NaN
false

> Object.is(NaN, NaN)
true
Enter fullscreen mode Exit fullscreen mode

Object.is() works just like === except these two cases, so next time when you see Object.is(), you can think of it roughly equivalent to === except these two minor details.

This is in fact the comparison method used in ReactJS Hooks, such as useEffect(), where the dependency array elements are compared using Object.is().

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more