Aug 31 2011 | 8:32 pm
    I don't get it. I got the following script: test="05A"; post ("test is "); post (test,"n"); post ( parseInt(test.slice(0,2)), "n"); test="08A"; post ("test is "); post (test,"n"); post ( parseInt(test.slice(0,2)), "n");
    This gives me the following output: js: test is 05A js: 5 js: test is 08A js: 0
    Why doesn't the second output give me 8?

    • Aug 31 2011 | 9:23 pm
      Never mind. This: post ( parseInt(test,10), "n"); works
    • Mar 29 2015 | 11:25 am
      I just had the same problem: parseInt('01'), parseInt('02'), etc. give properly 1, 2, etc. until parseInt('08') and parseInt('09') that give 0.
      my turnaround is to specify the radix, like parseInt('08',10) and parseInt('09',10); then it works. I find it confusing but the default radix depends on the input, see definition and usage.
    • Mar 30 2015 | 12:12 pm
      Starting the text representation of an integer with a spurious zero is, by longstanding convention, a flag to interpret the integer as an octal representation. Since the digits '8' and '9' aren't used in octal, the parser is likely to get confused.
      What happens if you drop the leading zero?