num % 1 != 0
The Number. isInteger() method determines whether a value an integer. This method returns true if the value is of the type Number, and an integer (a number without decimals). Otherwise it returns false.
function hasDecimal (num) { return !!(num % 1); } hasDecimal(2) // true hasDecimal(2.345) // false