parseInt() now parses leading-zero strings as decimal, not octal

Published: | Categories: JavaScript

Description

The parseInt method implementation has been updated to conform to the ECMAScript 5 spec, and it now parses leading-zero strings as decimal, not octal. Therefore, parseInt("042") will return 42 instead of 34. If you’d like to parse strings as octal, specify the radix like parseInt(str, 8).

References