Standard built-ins

Object.is()

Try the free JavaScript compiler

Tests SameValue equality without coercion. It treats NaN as equal to itself and distinguishes positive from negative zero, unlike strict equality. Objects still compare by identity.

Formal Syntax & Structure

javascript syntaxjavascript
Object.is(value1, value2)

Parameters & Attributes

NameTypeDescription
value1anyFirst value.
value2anySecond value.

Return Value

Boolean

True for SameValue equality.

Working Example

Example Snippetjavascript
console.log(Object.is(NaN, NaN), Object.is(0, -0));
JavaScript Reference