JS: isNaN

By Xah Lee. Date: . Last updated: .

isNaN is a global function object.

[see JS: the Global Object]

isNaN ( number )

Converts number to number first, and return true if it is NaN, else, false.

(NaN is a primitive value of number type that represents “not a number”.)

[see JS: NaN]

console.log ( isNaN ( NaN ) ); // true
console.log ( isNaN ( "NaN" ) ); // true

console.log ( isNaN ( "3" ) ); // false
console.log ( isNaN ( 3 ) ); // false
console.log ( isNaN ( Infinity ) ); // false

Number.isNaN and the global isNaN are different.

isNaN converts argument to number first. Number.isNaN does not.

[see JS: Number.isNaN]

Reference

ECMAScript® 2016 Language Specification#sec-isnan-number

Number Topic

  1. JS: Format Number
  2. JS: String to Number
  3. JS: Number Object
  4. JS: Number Constructor
  5. JS: Number.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon