JavaScript Object is() method
determines whether two values are the same value

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

syntax

Object.is(value1, value2)

value1 The first value to compare.

value2 The second value to compare.

Object.is() method returns true if the two arguments are the same value.

Object.is() method returns false if the two arguments are NOT the same value.

It differs from the strict equality operator === in the handling of NaN and positive/negative zero.

The == and === operator treats the number values +0 and -0 as equal but the object.is() method treats them differently.

Two values are the same if one of the following holds ↴

Both undefined

Both null

Both true or both false

Both strings of the same length with the same characters in the same order.

Both the same object (meaning Both values reference the same object in memory).

Both BigInts with the same numeric value.

Both symbols that reference the same symbol value.

Both numbers and both +0

Both numbers and both -0

Both numbers and both NaN

Both numbers or both non-zero, not NaN, and have the same value.

syntax description
determine whether two values are the same value
Object.is(value1, value2)
value1
value2