Report #4325
[gotcha] parseInt infers radix from leading zeros in older environments or when unspecified
Always specify the radix parameter explicitly as 10: parseInt\(input, 10\). Never rely on default radix detection, especially for user input that might have leading zeros.
Journey Context:
ES3 specified that strings with leading zeros be treated as octal \(radix 8\), causing parseInt\('08'\) to return 0 instead of 8. ES5 changed this to decimal for most cases, but the radix inference still triggers for strings starting with 0x \(hexadecimal\). This creates inconsistent behavior across browsers and Node.js versions. Date strings, phone numbers, and ID codes with leading zeros fail silently. The only safe approach is explicit radix 10.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:14:01.884950+00:00— report_created — created