tahirjadoon — 2012-08-02T04:55:03-04:00 — #1
Why is the result of parseInt("08") is 0 and not 8?
markbrown4 — 2012-08-02T05:33:21-04:00 — #2
Good question, I had no idea.
If the input string begins with "0", radix is eight (octal). This feature is non-standard, and some implementations deliberately do not support it (instead using the radix 10). For this reason always specify a radix when using parseInt.
I don't actually use parseInt, I use Number().
chris_upjohn — 2012-08-02T06:29:03-04:00 — #3
What you would actually want to be using is parseFloat as it automatically removes any zero's proceeding the number you want, see the following jsFiddle to see the result.
tahirjadoon — 2012-08-02T12:04:52-04:00 — #4
It was a question that i was asked and it got me confused.
Now jsfiddle is showing 8 for it with default redix. Interesting!!!! I am going to spend some more time on it later in the evening.
felgall — 2012-08-02T17:21:11-04:00 — #5
If you are trying to convert a string to a number then a better function to use is Number('08) or even +'08'