Maybe you thought that if you didn't pass the radix, then it would default to 10 because
it's the obvious behavior. Well, no. In JavaScript the default behavior is to try to
identify one of the literal formats and interpret that. So here's that in action:

If you are familiar with the literal notation for integer numbers in JavaScript,
and after I explained the default behavior of parseInt, then
you probaly understood the results shown above. Well, maybe the last one deserves
some comments.

When JavaScript is parsing the string, if it finds a digit (number or alpha) that is invalid
in the chosen radix, it stops right there and parses only the portion of the string that
comes before that digit. So, since we started '0182' with a leading zero, the
octal radix is assumed. Then, because 8 is not a valid octal digit, only '01'
will be parsed, which becomes 1.

Tip #1:
If there's any chance the string value you plan to parse into an integer number has
a leading zero (or a less likely 0x,) then be safe and pass the radix parameter
to your parseInt call. If you're extra paranoid, then always pass the radix.

Back to our original question

Armed with the clarification made above, we can expand our example like this:

Pick of the week: An Engineer's Guide to Bandwidth General Prefer Dependency Injection to Service Location : Steven Harman explains the difference between two common practices for using Inversion of Control containers and shares his opinion why one is