I am tring to use parseInt in a map
, but some strange behavor happened,
here is code:
["1","2"].map(parseInt)
the result is:
[1, NaN]
but when I wrap the parseInt
function:
["1","2"].map(function(n){ return parseInt(n)})
it works fine, the result is:
[1, 2]
why?