If there is a leading 0, it converts it to octal (base 8), if it has a real number in base 8 (the number is not more than 7).
For instance:
017 at the base of 8 is 1 * 8 + 7 = 15 037 at the base of 8 is 3 * 8 + 7 = 31
018 converts to 18 because 018 not a valid number in base 8
Please note that the behavior with respect to the base, according to which the number is converted by default, may be browser specific, therefore it is important to always specify base / radix when using parseInt :
parseInt("017",10) === 17
UPDATE based on comments:
parseInt expects a string as the first argument, therefore
parseInt("012",10) === 12
source share