Number.isInteger(value)
function isNumeric(num) {
if (num === '' || num === null) {
return false
}
return !isNaN(num)
}
isNumeric('') //false
isNumeric('7') //true
isNumeric(7) //true
isNumeric('7a') //false
isNumeric('a') //false
isNumeric(null) //false
isNumeric(0) //true
isNumeric('0') //true
isNumeric(true) //true
isNumeric(false) //true
// strict, matches only objects of type 'number'
// excluding Infinity and NaN.
function isNumber(n) {
return typeof n === 'number' && isFinite(n);
}
let testString="5";
if(Number.isInteger(parseFloat(testString))){
console.log("we are a int of some sort");
}
function isNumber(value) {
return !isNaN(value) && parseFloat(Number(value)) === value && !isNaN(parseInt(value, 10));
}