JavaScript · Middle · Question 57 of 75
What does new Array(3).map((_, i) => i) return?
- ✓Correct answer:
[ <3 empty items> ]-mapskips holes - 2
[0, 1, 2] - 3
[undefined, undefined, undefined]
Explanation
new Array(3) creates a sparse array without elements. Use Array.from({ length: 3 }, (_, i) => i) or [...Array(3).keys()].