parseInt(’08’) returns 0
After a quick bit of research when I had this problem, I discovered the parseInt function has an optional ‘radix’ parameter which specifies the base to use. By passing 10 as the base it solves the leading 0 issue, for example:
alert( parseInt('08', 10) );
will show the number 8 in an alert dialog, whereas:
alert( parseInt('08') );
would display 0.
To be on the safe side it’s probably always a good idea to pass the radix parameter to the parseInt function to ensure the values returned are what you expect them to be, especially if they might contain leading zeroes.