+ 9
JavaScript Map
Why does this code returns. (1, NaN, 3) let x = ["1", "7", "11"].map(parseInt) console.log(x)
3 Respostas
+ 1
probably sth with binary.
since
1b = 1d
11b = 3d
7 is not binary and cannot be converted so it becomes NaN
+ 1
Actually parseInt can take one argument. Radix parameter is optional. The thing is you missed calback in map method, so add lambda function:
["1","7","11"].map(o => parseInt(o))