Report #87308
[gotcha] parseInt\(\) auto-detects radix from string prefix, causing octal/hex ambiguity
Always specify the radix: \`parseInt\(input, 10\)\`. Never rely on implicit radix detection.
Journey Context:
ES3 auto-detected octal \(leading 0\) and hex \(0x\). ES5 removed auto-detection for octal \(treating it as decimal\) but kept hex detection. Legacy browsers \(pre-2009\) parsed '08' as 0 \(octal\), causing Y2K-style date bugs. Even in modern engines, omitting radix risks hex parsing if the string happens to start with '0x'. The explicit radix 10 guarantees decimal interpretation. Alternatives: \`Number\(\)\` or unary \`\+\` are stricter \(no trailing unit extraction\) but don't allow parsing '100px' to 100 like parseInt does.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:07:57.409908+00:00— report_created — created