Hacker News new | past | comments | ask | show | jobs | submit login

While JavaScript is parsing it as octal, this will cause a whole raft of errors if you are making your users enter dates.

User enters 08 for August, even returning NaN would be a mistake.




You can and should then pass the second radix parameter to parseInt:

    parseInt('08', 10) // => 8
This tells it explicitly that this is a base-10 number, rather than letting it guess at the base. You can also use this to decode things in base n, n <= 36.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: