3 ms·
Thanks for the chuckle. To save everyone from having to look this up on Stack Overflow: .map passes two arguments to the function it calls - the value and the
by danielvf 8y ago
Thanks for the chuckle.
To save everyone from having to look this up on Stack Overflow:
.map passes two arguments to the function it calls - the value and the index. The parseInt function takes up to two arguments, a string and a radix.
So there’s nothing broken here about .map, you just aren’t expecting the second optional argument for parseInt.
So the actual equivalents are:
['1','1','1'].map(parseInt)
And
['1','1','1'].map((n, index) => parseInt(n, index))