• archimonde

    The JavaScript parseInt function accepts the second argument (radix), which shuld be the a number representing the numeral system to be used.

  • Yes, it would be a good idea to always add 10 as a radix when using parseInt. But there are some scripts – most of them – that don’t specify the radix, one might just run into trouble at the beginning of August 😛

  • AlexB

    It’s always necessary to specify the radix in order to avoid this situation. Danny Goodman (author of JS Bible and Dynamic HTML: the definitive reference, etc.) says: “An optional second parameter to parseInt function enables you to specify the base of the number represented by the string. This comes in handy particularly when you need a decimal number from a string that starts with one or more zeros. Normally, the leading zero indicates an octal value. But if you force the conversion to recognize the string value as a decimal, it is converted the way you expect:” – excerpt from JS Bible 6th Ed.

Advertisment ad adsense adlogger