FlashcardBeginner

map passes (value, index): the parseInt trap

Array.map calls its callback with (value, index, array), which breaks parseInt because it treats index as the radix.

Question

Why does ['1','2','3'].map(parseInt) return [1, NaN, NaN] instead of [1, 2, 3]?

Click to reveal answer