how to check if a number is an integer in javacsript code example
Example 1: javascript is number an integer
Number.isInteger(value)
//returns a Boolean
Example 2: js check if string is integer
function isInt(str) {
return !isNaN(str) && Number.isInteger(parseFloat(str));
}
Example 3: To check if a value is a number in JavaScript
const value = 2
isNaN(value) //false
isNaN('test') //true
isNaN({}) //true
isNaN(1.2) //false