← Back to design patterns mapbehavioral
🔁
Design Pattern
Iterator
Traverse a collection without exposing how it is stored.
Visual Diagram
Collection -> iterator.next() -> item by item
When To Use
- ->Custom collection traversal
- ->Paginated API processing
- ->Lazy file or stream reading
- ->Generator-based flows
Used in: for...of, async iterators, streams
iterator.js
Live Editor
Loading...
Output
Run code to see output...