Possible Duplicate:
Workarounds for JavaScript parseInt octal bug
It seems as though leading zeroes should just be ignored when parsing for an Int. What is the rationale behind this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because it is parsed as an octal number, and not decimal.
From MDC:
(hexadecimal).
(octal). This feature is non-standard, and some implementations
deliberately do not support it (instead using the radix 10). For
this reason always specify a radix when using parseInt.
string begins with any other value, the radix is 10 (decimal).
To force it to parse as Decimal, just supply 10 as your second argument (base).