Since map callback gets called on each element, I would have expected [2,3] as the return value based on the documentation here.
Asked
Active
Viewed 85 times
1
-
2Please use the search before asking a new question: [`[javascript] map parseInt`](https://stackoverflow.com/search?q=%5Bjavascript%5D+map+parseInt) – Felix Kling May 10 '16 at 15:13
-
1Duplicate of http://stackoverflow.com/a/262511/1028949 – jeffjenx May 10 '16 at 15:14
-
1`map(Number)` is probably what you want. – Andy May 10 '16 at 15:14
-
This question was discussed recently. The issue is that parseInt takes 2 parameters, expression to evaluate and radix (10 by default). Change to ["3","2"].map(parseInt) and receive [11,NaN] – Alex Kudryashev May 10 '16 at 15:18
1 Answers
1
Simply use .map(Number)
for this type of task:
var a = ["2", "3"];
var b = a.map(Number);

omarjmh
- 13,632
- 6
- 34
- 42