Skip to content

Instantly share code, notes, and snippets.

@Kotrotsos
Last active July 13, 2021 09:45
Show Gist options
  • Save Kotrotsos/d821491d446c691a4061cfb06368f3ad to your computer and use it in GitHub Desktop.
Save Kotrotsos/d821491d446c691a4061cfb06368f3ad to your computer and use it in GitHub Desktop.
isNaN(NaN) // true
isNaN(undefined) // true
isNaN({}) // true
isNaN(true) // false
isNaN(null) // false
isNaN(37) // false
// strings
isNaN('37') // false: "37" is converted to the number 37 which is not NaN
isNaN('37.37') // false: "37.37" is converted to the number 37.37 which is not NaN
isNaN("37,5") // true
isNaN('123ABC') // true: parseInt("123ABC") is 123 but Number("123ABC") is NaN
isNaN('') // false: the empty string is converted to 0 which is not NaN
isNaN(' ') // false: a string with spaces is converted to 0 which is not NaN
// dates
isNaN(new Date()) // false
isNaN(new Date().toString()) // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment