How to find that a number is float or integer?
1.25 --> float
1 --> integer
0 --> integer
0.25 --> float
<
It really doesn't have to be so complicated. The numeric value of an integer's parseFloat() and parseInt() equivalents will be the same. Thus you can do like so:
function isInt(value){
return (parseFloat(value) == parseInt(value)) && !isNaN(value);
}
Then
if (isInt(x)) // do work
This will also allow for string checks and thus is not strict. If want a strong type solution (aka, wont work with strings):
function is_int(value){ return !isNaN(parseInt(value * 1) }