I know that you are interested in Integer numbers, so I wonβt answer that, but if you ever want to check the floating point numbers, you can do it.
function isFloat( x ) { return ( typeof x === "number" && Math.abs( x % 1 ) > 0); }
Note. This MAY handle numbers ending in .0 (or any logically equivalent number 0 ) as INTEGER. This actually requires a floating point precision error to detect floating point values ββin this case.
Ref.
alert(isFloat(5.2)); //returns true alert(isFloat(5)); //returns false alert(isFloat(5.0)); //return could be either true or false
Dan Oct 23 '13 at 17:56 2013-10-23 17:56
source share