Object.is Function (JavaScript)

Returns a value that indicates whether two values are the same value.

Syntax

Object.is(value1, value2)  

Parameters

value1
Required. The first value to test.

value2
Required. The second value to test.

Return Value

true if the value is the same value; otherwise, false.

Remarks

Unlike the == operator, Object.is does not coerce any types when testing values.

The comparison applied by Object.is is similar to the comparison applied by the === operator, except that Object.is treats Number.isNaN as the same value as NaN. It also treats +0 and -0 as different values.

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.