Created
August 17, 2012 12:52
-
-
Save kesla/3378547 to your computer and use it in GitHub Desktop.
.map(parseInt) fails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
['1', '2'].map(parseInt) | |
// output [1, NaN] | |
['1', '2'].map(Number) | |
// output [1, 2] | |
Why? |
dslming
commented
Aug 6, 2018
- when parseInt() receive second param, and this param is illegal, the result is fails.
- Function map() will send 3 params to parseInt, is value, index and array.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment