How to find that a number is float or integer?
float
integer
1.25 --> float 1 --> integer 0 --> integer 0.25 --> float <
1.25 --> float 1 --> integer 0 --> integer 0.25 --> float
function int(a) { return a - a === 0 && a.toString(32).indexOf('.') === -1 } function float(a) { return a - a === 0 && a.toString(32).indexOf('.') !== -1 }
You can add typeof a === 'number' if you want to exclude strings.
typeof a === 'number'