Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
TypeScript 4 Design Patterns and Best Practices

You're reading from  TypeScript 4 Design Patterns and Best Practices

Product type Book
Published in Sep 2021
Publisher Packt
ISBN-13 9781800563421
Pages 350 pages
Edition 1st Edition
Author (1):
 Theofanis Despoudis Theofanis Despoudis
Profile icon Theofanis Despoudis

Table of Contents (14) Chapters

Preface 1. Section 1: Getting Started with TypeScript 4
2. Chapter 1: Getting Started with Typescript 4 3. Chapter 2: TypeScript Core Principles 4. Section 2: Core Design Patterns and Concepts
5. Chapter 3: Creational Design Patterns 6. Chapter 4: Structural Design Patterns 7. Chapter 5: Behavioral Design Patterns 8. Section 3: Advanced Concepts and Best Practices
9. Chapter 6: Functional Programming with TypeScript 10. Chapter 7: Reactive Programming with TypeScript 11. Chapter 8: Developing Modern and Robust TypeScript Applications 12. Chapter 9: Anti-Patterns and Workarounds 13. Other Books You May Enjoy

The Iterator pattern

Iterator is an entity that knows how to traverse a list of elements in a collection in an abstracted way. You can think of this pattern as an abstraction over for loops. The main idea is that you want to iterate over a data structure without knowing its inner details or how to access its elements in a particular order. You may want to traverse the elements in a direct or reversed order by simply requesting the right Iterator object.

An analogy of this pattern is when you have a saved list of favorite shows on your hard drive. Each of these videos is saved in a different folder, but you can iterate over them one by one from your UI view without knowing the details of their location in the disk.

We explain in detail when to use this pattern next.

When to use the Iterator pattern?

You want to consider using an Iterator for the following use cases:

  • Traversing a complex data structure: When you have a data structure that is not traversable via a...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}