["1","2","3"].map(parseInt);
Copy the code

map

Array. map(function(currentValue,index,arr),thisValue) CurrentValue: The current element value; Index: index of the current element; ThisValue is optional. This object is used as the callback function, passed to the function, and is used as the this value. If thisValue is omitted or undefined or null is passed in, the this value of the callback is the global object.Copy the code

parseInt

ParseInt (string,radix) parseInt(string,radix) resolves to decimal integers. If the argument starts with 0x or 0x and the second argument is omitted, the number is parsed in base 16. parseInt("0xa"); // 10 parseInt("0xa",16); // 10 parseInt("0xa",2); // radix: Optional, the radix of the number to be resolved is between 2 and 36; If the argument is omitted or 0, the number is parsed as base 10. If this parameter is less than 2 or greater than 36, NaN is returned; Note: 1. Only the first number in the string is parsed; 2. Allow Spaces before and after strings. If the first part of the string is not a number, NaN is returned.Copy the code
["1","2","3"].map((value,index)=>parseInt(value,index)); // [1,NaN,NaN]
parseInt("1",0);
parseInt("2",1);
parseInt("3",2);
Copy the code