JavaScript · Middle · Question 49 of 75
What does Array.from({ length: 3 }, (_, i) => i * 2) return?
- ✓Correct answer:
[0, 2, 4] - 2
[undefined, undefined, undefined] - 3
[]
Explanation
Array.from creates an array from an iterable or array-like object ({ length: 3 }), and the second argument is a mapping function. It's a handy way to generate ranges. new Array(3) creates an array with "holes" that map skips.