Object

Object.is

Determines whether two values are the same value using the SameValue algorithm

Syntax

JavaScript
Object.is(value1, value2)

Parameters

ParameterTypeDescription
value1anyThe first value to compare
value2anyThe second value to compare

Return Value

true if the values are the same, false otherwise

Examples

Basic Usage
console.log(Object.is(NaN, NaN)); // true (unlike ===)
console.log(NaN === NaN); // false
Practical Example
console.log(Object.is(0, -0)); // false (unlike ===)
console.log(0 === -0); // true
Advanced Usage
console.log(Object.is('foo', 'foo')); // true
console.log(Object.is(null, null)); // true
console.log(Object.is(undefined, null)); // false

Understanding Object.is

The Object.is method in JavaScript determines whether two values are the same value using the SameValue algorithm. It belongs to the Object object and is one of the most widely used methods for working with object values in modern JavaScript and TypeScript applications.

The method signature is Object.is(value1, value2). It accepts 2 parameters: value1, value2. When called, it returns true if the values are the same, false otherwise. Understanding when and how to use is() helps you write more expressive, readable code.

Common use cases for Object.is include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like object-keys, number-isnan, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Object.is is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Object Methods

Other methods in the Object object

Related Tools

More Object Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.