how to know if a number has a decimal number js

JavaScript
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
Source

Also in JavaScript: