Why ['1', '7', '11'].map(parseInt) returns [1, NaN, 3] in Javascript

Eric Tong
Eric Tong
Jun 12, 2019 · 5 min read
???

Javascript is weird. Don’t believe me? Try converting an array of strings into integers using map and parseInt. Fire up your console (F12 on Chrome), paste in the following, and press enter (or run the pen below).

['1', '7', '11'].map(parseInt);