Always use a radix with [[js]] parseInt
.
parseInt(number, radix)
The radix sets the 'base', which you usually want to be decimal (base 10).
If you don't use a radix, the default is considered to be 8
. For numbers that start with a 0
, this will lead to them being treated as an octal, where something like 010
is 8
, not 10
.