js is integer string code example
Example 1: js check if string is integer
function isInt(str) {
return !isNaN(str) && Number.isInteger(parseFloat(str));
}
Example 2: how to check if a string is an integer javascript
isNaN(num) // returns true if the variable does NOT contain a valid number
Example 3: js is variable int
// The === operator is used for checking
// the value and the type of a variable
var data = 1;
if (data === parseInt(data, 10))
alert("data is integer")
else
alert("data is not an integer")