Using the Javascript function parstInt() on the strings '08' and '09' returns 0. This is due to the
design of parseInt. All numbers starting with 0 are assumed to be in octal, and since 08 and 09 don't
exist in octal, 0 is returned. It is the same as how you might expect numbers beginning with 0x are
hexidecimal, and parseInt does assume this.
var intValue1 = parseInt('05');
var intValue2 = parseInt('08');
alert(intValue1 + ', ' + intValue2); // Alerts '5, 0'
This parseInt functionality is very unintuitive, but thankfully easy to correct. The second parameter to
the parseInt function is the radix. Since the radix changes from 10 to 8 to 16 depending on the string
passed in, you can explicitly set the radix to 10 when parseInt is called:
var intValue1 = parseInt('05', 10);
var intValue2 = parseInt('08', 10);
alert(intValue1 + ', ' + intValue2); // Alerts '5, 8'
http://stackoverflow.com/questions/850341/workarounds-for-javascript-parseint-octal-bug