I feel like this classic gem should also be included (if it is not there already and I missed it):
[1,2,3].map(parseInt)
// [ 1, NaN, NaN ]
Explanation:
map passes three arguments to parseInt for each iteration, and parseInt accepts the second argument (undefined) as radix, and fails silently. [1,2,3].map((x) => parseInt(x)) works.
I feel like this classic gem should also be included (if it is not there already and I missed it):
Explanation:
map
passes three arguments toparseInt
for each iteration, andparseInt
accepts the second argument (undefined
) as radix, and fails silently.[1,2,3].map((x) => parseInt(x))
works.Links:
Doc: