Javascript Design Patterns #4 - Iterator Pattern

preview_player
Показать описание
What is the Iterator design pattern?
The Iterator pattern is a pattern that allows you to effectively loop over a collection of objects. A common programming task is to traverse and manipulate a collection of objects. These collections may be stored as an array or perhaps something more complex, such as a tree or graph structure. In addition, you may need to access the items in the collection in a certain order, such as, front to back, back to front, depth first (as in tree searches), skip evenly numbered objects, etc.

The Iterator design pattern solves this problem by separating the collection of objects from the traversal of these objects by implementing a specialized 'iterator'!

📚Materials/References:

🌎 Find Me Here:

Рекомендации по теме
Комментарии
Автор

Great explanation and to the point. I watched some other ones that were almost a half hour long and learned nothing. Overly complex and left me confused unlike your video. Thank you, please continue your tutorials!

Cambaudio
Автор

Very clear explanation and easy to understand examples. I love you vids man. Keep em coming

TheRealBwoi
Автор

Really good material on this channel that has already helped thousands, and thousands to come! keep up the good work its much appreciated to find gems

Bobby-opip
Автор

Thank you again for all the great work 🙏😀 I see that switch to the dark theme btw, nice!

cody_codes
Автор

Your videos have been super helpful... Thank you!!!!

celestecolamarino
Автор

I will "Iterate" throw this channel to learn more stuff!

neuodev
Автор

Thanks for the video. man! Simple and well explained!

BORIS_NEKEZOV
Автор

Great series. Vanillajs tutorials are very few

jora
Автор

I can do this with while loop directly(without additional function call overhead), So what is the advantage here? Where does we use these pattern? Is this just for good readable code.

JustinJohnMathews
Автор

I think that for better readability you should not shadow global variables (items). It can confuse newbies.

spunkyPL
Автор

What's the point in using this over a standard for-loop ?

dorianslavov
Автор

great tutorial. I am noticing that you are using diffent websites for each tutorial, can I ask why?

Uyghur_Ata
Автор

why didn't we just define the methods hasNext and next inside the function Iterator itself? why did we use prototype here?

vaneetgupta
Автор

From where did . Prototype come from? 🤔🤔 Hasnext and next ⁉️

aaf
Автор

hi,
i've learned a lot about design patterns(theory mainly). Most of the time they are explained for languages that implement interfaces (java, php, typescript etc...)
Do you know a way to simulate interfaces in javascript?

jeanmarcpourchel
Автор

An iterator in js seems kinda pointless to me, but maybe it makes sense to use them for very complex programs.

matijatu
Автор

I know Some java frameworks follows this pattern.

prabu
Автор

Scanner scanner = new Scanner(items);
while(scanner.hasNext()) {

}

oridubi
visit shbcf.ru