Map and parseInt developer.mozilla.org/zh-CN/docs/…

First parseInt(string, radix) takes two arguments, the first representing the value being processed (string) and the second representing the radix at the time of parsing, the base number:

function returnInt(element) {
  returnparseInt(element, 10); } parseInt(10,0) //10 radix = 0; parseInt(10,1) //NaN = 0 So 3 to the 0 times 0 plus 3 to the 1Copy the code

So the first parameter can’t be greater than the second parameter if it’s less than 10

ParseInt (3,2) // The binary of NaN 3 is 10. ParseInt (9,8) // the octal of NaN 9 is 10Copy the code

After the map

var new_array = arr.map(function callback(currentValue[, index[, array]]) {
 // Return element forNew_array}[, thisArg]) callback generates a new array element using three arguments: currentValue Current element being processed in the callback array. Index The index of the current element being processed in the optional callback array. Array Array in which the optional callback map method is called. ThisArg Optional this value to use when executing the callback function. Eg: [1, 2, 3]. The map (function(a,b,c){console.log(a,b,c)})

1 0 [1, 2, 3]
2 1 [1, 2, 3]
3 2 [1, 2, 3]
Copy the code

So the arrays they return are, respectively

ParseInt (1,0) // decimal 1 parseInt(2,1) //1 is invalid parseInt(3,2) // binary 3 is 10 so the actual result is [1, NaN, NaN]Copy the code