javascript how to check if a number code example
Example 1: check if input is a number javascript
// Another option is typeof which return a string
if (typeof(val) === 'number') {
// Guess what, it's a bloody number!
}
Example 2: javascript check if variable is number
function isNumber(n) {
return !isNaN(parseFloat(n)) && !isNaN(n - 0);
}