When running
["6", "1", "0", "3", "3"].map(parseInt)
in the JavaScript console in my browser, I get the output
[6, NaN, 0, NaN, 3]
! But I was expecting
[6, 1, 0, 3, 3]
.
It seems that this might have to do with the fact that parseInt can accept two arguments instead of one. I was under the impression that map
merely called the given function on each element of the array separately. Can somebody clarify how map works and why it leads to this odd behavior?