Skip to content

Instantly share code, notes, and snippets.

@jonahsnider
Last active January 9, 2022 23:18
Show Gist options
  • Save jonahsnider/91fd46f350b4248dbccc44451e4c7003 to your computer and use it in GitHub Desktop.
Save jonahsnider/91fd46f350b4248dbccc44451e4c7003 to your computer and use it in GitHub Desktop.
Number validation with built-in JS
Input !Number.isNaN(x) !isNaN(x) typeof x === 'number' isFinite(x) Number.isFinite(x) Number.isInteger(x) Number.isSafeInteger(x)
123
"123"
NaN
"NaN"
"hello"
"0x123"
Infinity
Number.MAX_SAFE_INTEGER + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment