JavaScript · Middle · Question 28 of 75

What does your own object need to work with for...of and spread?

Explanation

The iteration protocol: [Symbol.iterator] returns an object with next() that yields { value, done }. The easiest implementation is a generator. Objects with length are array-likes: they don't work with for...of and are converted with Array.from.

Further reading

Problem with a question

JavaScript · Middle · question 28

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