Design Patterns · Junior · Question 13 of 75

Which pattern do for...of and Symbol.iterator implement?

Explanation

An iterator gives a uniform way to traverse a collection sequentially without exposing its internals. Arrays, Map, Set, strings and generators implement the iteration protocol, so they work the same in for...of and spread.

Further reading

Problem with a question

Design Patterns · Junior · question 13

Test yourself

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

Take this quiz