How to find that a number is float
or integer
?
1.25 --> float
1 --> integer
0 --> integer
0.25 --> float
<
In java script all the numbers are internally 64 bit floating point
, same as double in java.
There are no diffrent types in javascript, all are represented by type number
. Hence you wil l not be able make a instanceof
check. However u can use the above solutions given to find out if it is a fractional number. designers of java script felt with a single type they can avoid numerous type cast errors.