Oh, I see now. There is a conflict between the two parameters (index and base). Since the code you mentioned returns [0, NaN, NaN], why does it return 0 in the "zeroth" element of the array? What even is a base 0 number to JavaScript?
As I experimented on passing in 0 as an argument for the base parameter of parseInt, I found that it works normally. Why would that work? Is it just all in the spec?
From MDN (radix being the same as base with the previously used verbage):
If radix is undefined or 0 (or absent), JavaScript assumes the following:
If the input string begins with "0", radix is eight (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 specifies that 10 (decimal) is used, but not all browsers support this yet. For this reason always specify a radix when using parseInt.
Oh, I see now. There is a conflict between the two parameters (
indexandbase). Since the code you mentioned returns[0, NaN, NaN], why does it return0in the "zeroth" element of the array? What even is a base 0 number to JavaScript?As I experimented on passing in
0as an argument for thebaseparameter ofparseInt, I found that it works normally. Why would that work? Is it just all in the spec?From MDN (
radixbeing the same asbasewith the previously used verbage):Thanks for looking into this! We appreciate your efforts. I'll go make a quick edit to the article now to raise this point.