Object.is()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.

The Object.is() static method determines whether two values are the same value.

Try it

console.log(Object.is("1", 1));
// Expected output: false

console.log(Object.is(NaN, NaN));
// Expected output: true

console.log(Object.is(-0, 0));
// Expected output: false

const obj = {};
console.log(Object.is(obj, {}));
// Expected output: false

Syntax

js
Object.is(value1, value2)

Parameters

value1

The first value to compare.

value2

The second value to compare.

Return value

A boolean indicating whether or not the two arguments are the same value.

Description

Object.is() determines whether two values are