3 ms·
I tend to avoid parseInt unless I explicitly need a specific radix. I find the Number function much more reliable in parsing numbers. ['1', '7', '11'].map(
by janpot 6y ago
I tend to avoid parseInt unless I explicitly need a specific radix. I find the Number function much more reliable in parsing numbers.
['1', '7', '11'].map(Number)
And if I explicitly need integers I can always filter the result
['1', '7', '11'].map(Number).filter(Number.isInteger)
It also doesn't silently parse '123thisisnotanumber' or `0x11`