isNaN

Checks if a value when converted to a number is a special value NaN (not a number).

Note

isNaN differs from Number.isNaN in that isNaN converts the tested value to a number, while Number.isNaN does not. This may lead to unintuitive results, for example isNaN of string returns true because the string is converted to NaN which is a special value for not a number, however if the string is empty, Number.isNaN returns false because the empty string is converted to 0 which is a number.

In Math mode, bigfloat throws when converting it to a number, and thus isNaN will throw.

Syntax

function isNaN(value)

Parameters

Return value

Returns true if the value is NaN, false otherwise.

Examples

isNaN(NaN)
true
isNaN(1)
false
isNaN(Math.sqrt(-1))
true
isNaN("a string")
true
isNaN("")
false
Number.isNaN("a string")
false

See also