JavaScript · Middle · Question 57 of 75

What does new Array(3).map((_, i) => i) return?

Explanation

new Array(3) creates a sparse array without elements. Use Array.from({ length: 3 }, (_, i) => i) or [...Array(3).keys()].

Further reading

Problem with a question

JavaScript · Middle · question 57

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz