Re:Opera moves to WebKit
by papsosouid on Wednesday February 13, 2013 @12:35PM
(#5214385)
We're not talking about parsing in base 10, we're talking about parsing in base 8. I need to be able to tell if the parse succeeded or not, silently hiding errors is bad. The correct behaviour demonstrated in perl and python:
[ Parent
| on HN ]
Got to admit, I am disappointed that
> parseInt("08", 8);
returns 0 instead of NaN
Returning 0 makes perfect sense. parseInt matches an integer from the beginning of the string, so it reads the 0 and then stops at the 8 because 8 is not a valid digit in base 8.
>>> parseInt("123foobar", 10)
123