8 ms·
> A better default behavior would have been to use a default radix (base 10) and have an option for auto-detected radix (e.g. strings that begin with 0x). Not
by masklinn 16y ago
> A better default behavior would have been to use a default radix (base 10) and have an option for auto-detected radix (e.g. strings that begin with 0x).
Note that the option exists (provide `0` as radix). It's just stupid that the default radix is `0` (or `undefined`) and not `10`.
Not to mention, that would put parseInt in line with Number.toString(radix), which (sensibly) defaults to base 10 (side note: I was surprised and impressed to see that Number.toString can handle any base from 2 to 36 included)