check int javascript code example
Example 1: javascript check if number
if (Number.isInteger(val)) {
}
if (isNaN(val)) {
}
if (typeof(val) === 'number') {
}
Example 2: integer check in javascript
var a=Number.isInteger(5);
var b= Number.isInteger(01);
var c=Number.isInteger("10");
console.log(a,b,c);
Example 3: javascript check if number
function isNumber(n) { return /^-?[\d.]+(?:e-?\d+)?$/.test(n); }
------------------------
isNumber('123');
isNumber('123abc');
isNumber(5);
isNumber('q345');
isNumber(null);
isNumber(undefined);
isNumber(false);
isNumber(' ');