Javascript’s parseInt function does not seem to completely work.
parseInt("01") returns 1
parseInt("02") returns 2
parseInt("03") returns 3
parseInt("04") returns 4
parseInt("05") returns 5
parseInt("06") returns 6
parseInt("07") returns 7
parseInt("08") returns 0
parseInt("09") returns 0
You can’t explain that. Give it a try. (jsFiddle)
Edit Since this question was asked and answered, the “feature” of defaulting to octal radix has been deprecated. [1] [2]
This is because if a number starts with a ‘0’, it’s treated as base 8 (octal).
You can force the base by passing the base as the 2nd parameter.
According to the docs, the 2nd parameter is optional, but it’s not always assumed to be 10, as you can see from your example.