In this video Emmanuel Henri explains the iterator pattern with an example.
- [Instructor] The iterator pattern is a method…of iterating through a list of items,…whereas the chain of responsibility would use…more of a handler type and go through a chain.…The iterator is best used with a for loop…and is perfect when you want to iterate…through arrays of objects.…So let's go back to our base code here,…and let's erase everything that we see on screen.…So, Command-all, erase that, and then let's go through…our react code again.…So let's bring up react, I'm going to drag and drop this…to Visual Studio Code, and in the App.js,…copy line ten through 21, like so.…
And let's go back here.…And what we're going to do, in this code here,…we'll create a newsFeed array.…And inside of that array, we'll paste the code…that we just copied, and let's just remove…the news1, news2 and news3,…because this is an array of objects, perfect.…Once you have this, we can take a look…at some code for the iterators.…So this is how it works.…
You would do a for and then inside of the for,…you would do let feed of newsFeeds,…
- What's a pattern?
- What's the role of callbacks?
- Creational patterns, including Singleton and Factory
- Structural patterns, including model-view-controller
- Behavioral patterns, including Memento and Mediator
Skill Level Intermediate
2. Creational Patterns
3. Structural Patterns
4. Behavioral Patterns
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.