Iterator પેટર્ન એક સંગ્રહને ક્રમશः ટ્રાવર્સ કરવાની રીત પ્રદાન કરે છે તેના આંતરિક માળખાને ખુલ્લા પાડ્યા વિના. તે એટલો મૂળભૂત છે કે તે મોટાભાગની આધુનિક ભાષાઓમાં બનેલો છે (for-of લૂપ્સ, iterators, generators).
Iterator પેટર્ન શું કરે છે
ITERATOR → access elements of a collection SEQUENTIALLY without exposing its internals:
→ provides a standard way to traverse (next element, has more?)
→ the collection's internal structure (array, tree, linked list) is HIDDEN
→ decouples traversal logic from the collection
→ "iterate without caring how the collection is structured"
