Using Number.isNaN() to Check for NaN in Javascript


Determine if a value is NaN (Not-a-Number) more reliably than the global isNaN().

Source Code

console.log(Number.isNaN(NaN)); // true
console.log(Number.isNaN(0 / 0)); // true
console.log(Number.isNaN("text" * 2)); // true
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments