parseInt('1') = 1
parseInt('01') = 1
parseInt('5') = 5
parseInt('05') = 5
parseInt('8') = 8
But why:parseInt('08') = 0
parseInt('09') = 0
Always use the overload that takes the radix as the second parameter:
parseInt('011',10) = 11
here is a hint:
parseInt('011') = 9
If it's starting with 0 it's parsed as an octal number.
Numbers start with 0
(not 0x
) are octal numbers. Therefore 8
and 9
are not a valid octal numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With