what is ['1','2','3'].map(parseInt) result
javascript
Solution
Check out this article: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
The callback function is specified as:
callback
Function that produces an element of the new Array, taking three arguments:
currentValue
The current element being processed in the array.
index
The index of the current element being processed in the array.
array
The array map was called upon.
Therefore your `map()` function expands into:
parseInt('1', 0, the_array) # 1
parseInt('2', 1, the_array) # NaN
parseInt('3', 2, the_array) # NaN
Problem
``` ['1','2','3'].map(parseInt) ``` return `[1, NaN, NaN]` I don't know why? In my opinion is like this: ``` ['1','2','3'].map(function(i){return parseInt(i,10)}) ``` return `[1, 2, 3]` ====================================================== and other `['1','2','3'].map(parseFloat)` return `[1, 2, 3]`