parseInt('07')=='7', but parseInt('08')=='0'? why?

Posted by KOHb on Stack Overflow See other posts from Stack Overflow or by KOHb
Published on 2010-04-08T17:40:16Z Indexed on 2010/04/08 17:43 UTC
Read the original article Hit count: 173

Filed under:

Here's a simple script that gives a strange result:

alert(parseInt('01')+' - '+parseInt('02')+' - '+parseInt('03')+' - '+parseInt('04')+' - '+parseInt('05')+' - '+parseInt('06')+' - '+parseInt('07')+' - '+parseInt('08')+' - '+parseInt('09')+' - '+parseInt('10'));

I would expect it to give 1 - 2 - 3 and so on, but it gives me this (in FireFox, Chrome and IE6):

1 - 2 - 3 - 4 - 5 - 6 - 7 - 0 - 0 - 10

Can someone please explain me why?

© Stack Overflow or respective owner

Related posts about JavaScript