Array.prototype.map
passes more than one arguments to the callback. In particular the second argument it passes is the index of the element being processed.
parseInt
accepts more than one argument. In particular the second argument it accepts is the base of the numeric system you are converting from.
When the second element is processed you are calling parseInt("2.2", 1)
, and since 2
is not a valid digit in base 1 the result is NaN
.
If you declare a "wrapper" callback around parseInt
then these additional arguments are lost and everything seems to work correctly, although you should always pass the second argument to parseInt
.