---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# NaN

The global **`NaN`** property is a value representing Not-A-Number.

## Value

The same number value as [`Number.NaN`](./Number/NaN.mdx).

## Description

`NaN` is a property of the _global object_. In other words, it is a variable in global scope.

In modern browsers, `NaN` is a non-configurable, non-writable property. Even when this is not the case, avoid overriding it.

There are five different types of operations that return `NaN`:

- Failed number conversion (e.g. explicit ones like `parseInt("blabla")`, `Number(undefined)`, or implicit ones like `Math.abs(undefined)`)
- Math operation where the result is not a real number (e.g. `Math.sqrt(-1)`)
- Indeterminate form (e.g. `0 * Infinity`, `1 ** Infinity`, `Infinity / Infinity`, `Infinity - Infinity`)
- A method or expression whose operand is or gets coerced to `NaN` (e.g. `7 ** NaN`, `7 * "blabla"`) — this means `NaN` is contagious
- Other cases where an invalid value is to be represented as a number (e.g. an invalid `new Date("blabla").getTime()`, `"".charCodeAt(1)`)

`NaN` and its behaviors are not invented by JavaScript. Its semantics in floating point arithmetic (including that `NaN !== NaN`) are specified by [IEEE 754](https://en.wikipedia.org/wiki/Double_precision_floating-point_format). `NaN`'s behaviors include:

- If `NaN` is involved in a mathematical operation (but not [bitwise operations](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators#bitwise_shift_operators)), the result is usually also `NaN`. (See see [silently escaping NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN#silently_escaping_nan) for a counter-example.)
- When `NaN` is one of the operands of any relational comparison (`>`, `<`, `>=`, `<=`), the result is always `false`.
- `NaN` compares unequal (via [`==`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Equality), [`!=`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Inequality), [`===`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Strict_equality), and [`!==`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Strict_inequality)) to any other value — including to another `NaN` value.

`NaN` is also one of the [falsy](https://developer.mozilla.org/docs/Glossary/Falsy) values in JavaScript.
