← BYTES
JavaScript·Intermediate·Ref: 3.2.19

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

Have a question about this video? Mention reference 3.2.19 when you contact us.

a.[0, 2, 4]
b.[0, 1, 2]
c.An error, since {length: 3} is not an array
d.[undefined, undefined, undefined]
`Array.from()` accepts any array-like or iterable (even a plain object with just a `length` property) plus an optional mapping function applied to each generated index, here doubling each index 0,1,2 to produce [0, 2, 4].

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES3219#JavaScript