What is the output?
console.log([1, 2, 3].map((x, i, arr) => arr.length));
- [3, 3, 3]
- [1, 2, 3]
- [0, 1, 2]
- [3]
The third callback argument is the whole array, whose length is 3 each time.
Play Problem Solving ▸
console.log([1, 2, 3].map((x, i, arr) => arr.length));