What will happen in the console / Parsing ['1', '2', '3'].map(parseInt)

Опубликовано: 10 Июнь 2026
на канале: Игорь Антонов — про JavaScript и разработку
2,359
164

A friend of mine (Sasha, hi!) gave me this problem to solve. Take a look at this single line of code and try your hand at being a JavaScript engine. What will be the output?

['1', '2', '3'].map(parseInt); // ?

So, let's check? Drumroll:

[1, NaN, NaN]

If your answer matches, feel free to turn off this video. I have nothing new to tell you. But if the answer doesn't match, let's figure it out.

Contents:

00:00 Problem Statement
00:39 Writing the Code
01:35 Checking the Answer
02:49 The ParseInt Method
03:56 The Map Method
05:20 Examining the Code
06:43 Problem Found
08:19 Summary

Useful Links:

My blog on Telegram: https://t.me/antonovjs
https://developer.mozilla.org/en-US/d...
https://developer.mozilla.org/en-US/d...