Bart Veneman

Creator of Project Wallace, analytics for CSS. <noscript>-fanboy. Serverless clearfix engineer. I can lift node_modules twice my own weight.

Differences between window.isNaN() and Number.isNaN()

TIL the global isNaN() function and Number.isNaN() are different

global isNaN() coerces into a number
Number.isNaN() (ES6) doesn't, and only returns true for NaN pic.twitter.com/CF90IA880A

— Amelia Wattenberger 🪷 華曼如 (@Wattenberger) May 5, 2020
window.isNaN(undefined)
//=> true

window.isNaN(NaN)
//=> true

window.isNaN('')
//=> false

Number.isNan(undefined)
//=> false

Number.isNan(NaN)
//=> true

Number.isNaN('')
//=> false

Tags