Skip to content

Instantly share code, notes, and snippets.

Last active Feb 23, 2017
What would you like to do?
Test if its a number in JS
function isNumber(val) {
// only returns true if its a number
return Number(val) === val;
// OR
function isAlsoNumber(val) {
return typeof val === 'number' && !Number.isNaN(val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment