Why aren't the two following statements equivalent:
const output1 = [..."123"].map(parseInt);
const output2 = [..."123"].map(e => parseInt(e));
console.log(output1);
console.log(output2);
What concept am I missing?
Why aren't the two following statements equivalent:
const output1 = [..."123"].map(parseInt);
const output2 = [..."123"].map(e => parseInt(e));
console.log(output1);
console.log(output2);
What concept am I missing?
map will pass the index it is currently looking at as the second argument to the callback function.
parseInt takes an optional second argument which sets the radix (number base) it is parsing from.