# The Object is() method

> Learn how the JavaScript Object.is() method compares two values for equality, including how it treats NaN as equal and tells 0 apart from -0, unlike ===.

Author: Flavio Copes | Published: 2019-04-08 | Canonical: https://flaviocopes.com/javascript-object-is/

This method was introduced in ES2015. It aims to help comparing values.

Usage:

```js
Object.is(a, b)
```

The result is always `false` unless:

- `a` and `b` are the same exact object
- `a` and `b` are equal strings (strings are equal when composed by the same characters, in the same order)
- `a` and `b` are equal numbers (numbers are equal when their value is equal)
- `a` and `b` are both `undefined`, both `null`, both `NaN`, both `true` or both `false`

`0` and `-0` are different values in [JavaScript](https://flaviocopes.com/javascript/), so pay attention in this special case (convert all to `+0` using the `+` unary operator before comparing, for example).
