JavaScript · Middle · Question 49 of 75

What does Array.from({ length: 3 }, (_, i) => i * 2) return?

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.

Further reading

Problem with a question

JavaScript · Middle · question 49

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