I have the following two parseInt() and I am not quite sure why they gave me different results:
alert(parseInt(0.00001))
shows 0;
alert(parseInt(0.00000001))
shows 1
My guess is that since parseInt needs string parameter, it treats 0.00001
as ""+0.00001
which is "0.00001"
, therefore, the first alert will show 0
after parseInt. For the second statement, ""+0.00000001
will be "1e-8"
, whose parseInt will be 1
. Am I correct?
Thanks