Favorites

JavaScript Object.is() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Object.is()
JavaScript Object Static methodThis method is supported by all modern browsers.
Updated 28th November 2026

The Object.is() static method checks whether two values are the same, like === but treating NaN as equal to itself and +0 and -0 as different.

Description

The Object.is() static method determines whether two values are the same value. It behaves like === with two exceptions: Object.is(NaN, NaN) is true, and Object.is(0, -0) is false. Objects are still compared by reference. It's mainly useful in libraries that need exact comparisons, such as change detection.

Its comparison is called the SameValue algorithm. Arrays and Map keys use a slightly different version, SameValueZero, which treats NaN as equal to itself but +0 and -0 as the same, which is why includes() can find NaN.

Frameworks such as React use Object.is() to decide whether a value has changed, so state updates that set the same object, even with different contents, don't trigger a re-render. That's why updates are usually made by creating new objects rather than mutating existing ones.

Syntax

Object.is(value1, value2)

Parameters

  • value1The first value.
  • value2The second value.

Return Value

true if the two values are the same value, otherwise false.

Example

console.log(Object.is(NaN, NaN), NaN === NaN);
console.log(Object.is(0, -0), 0 === -0);
console.log(Object.is('a', 'a'));
console.log(Object.is({}, {}));

Browser Support

The following information will show you the current browser support for the Object.is() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee