check if number is integer js code example
Example 1: javascript check if number
if (Number.isInteger(val)) {
}
if (isNaN(val)) {
}
if (typeof(val) === 'number') {
}
Example 2: javascript is number an integer
Number.isInteger(value)
Example 3: 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 4: javascript check if a value is an int
Number.isInteger(2);
Number.isInteger(90);
Number.isInteger("37");
Number.isInteger(false);
Example 5: js check if string is integer
function isInt(str) {
return !isNaN(str) && Number.isInteger(parseFloat(str));
}