Check NaN in JavaScript

Level 131 keystrokes

Uses Number.isNaN() to check whether NaN (Not a Number) is NaN, and prints true.

JavaScript code

// NaN is never equal to anything, even itself (NaN === NaN is false)
// So Number.isNaN() is the reliable test; it returns true here
1console.log(Number.isNaN(NaN));

Output

true
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • .× 2
  • (× 2
  • )× 2
  • ;× 1

More JavaScript examples at level 1

← JavaScript typing practice