Javascript Design Patterns #4 - Iterator Pattern

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии • 37

  • @DevSage
    @DevSage  3 года назад

    🤖 GitHub: github.com/pkellz/devsage/blob/master/DesignPatterns/IteratorPattern.js
    📕 "Design Patterns Explained Simply" Ebook - payhip.com/b/MLtJ
    💙 Twitter: twitter.com/realDevSage
    📙 Ebooks: payhip.com/devsage
    💥 Discord: discord.gg/BP8wPv6raA

  • @Cambaudio
    @Cambaudio 4 года назад +6

    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!

    • @DevSage
      @DevSage  4 года назад +1

      Glad I could help!

  • @TheRealBwoi
    @TheRealBwoi 5 лет назад +8

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

    • @DevSage
      @DevSage  5 лет назад +1

      Preciate that 👍

  • @Bobby-op6ip
    @Bobby-op6ip 2 года назад +1

    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

    • @DevSage
      @DevSage  2 года назад

      This comment made me smile. Appreciate that 💯

  • @cody_codes
    @cody_codes 4 года назад +1

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

  • @neuodev
    @neuodev 2 года назад +1

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

  • @JustinJohnMathews
    @JustinJohnMathews 4 года назад +7

    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.

    • @TheMCVR
      @TheMCVR 4 года назад +2

      Very good question.... Waiting for answer from Devsage

    • @juancamilomejiazuluaga8372
      @juancamilomejiazuluaga8372 4 года назад +3

      I think is because you can set up you own rules to move over the array

    • @calmsh0t
      @calmsh0t 3 года назад +1

      it becomes handy for more complex traversels. You could for example implement a tree traversel with this and extract out the formula for checking and finding a nodes children.

  • @dorianslavov3371
    @dorianslavov3371 3 года назад +2

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

  • @celestecolamarino813
    @celestecolamarino813 3 года назад +2

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

    • @DevSage
      @DevSage  3 года назад

      Glad you like them!

  • @Uyghur_Ata
    @Uyghur_Ata 5 лет назад +5

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

    • @DevSage
      @DevSage  5 лет назад +1

      Thanks. Sometimes a website lags really bad while I'm recording. When that happens, I try to use a different site

    • @anonymoususer5402
      @anonymoususer5402 4 года назад +1

      He is not only changing websites, he also is switching os, windows to ubuntu and again windows 😂

  • @BORIS_DIGITAL_HUB
    @BORIS_DIGITAL_HUB 3 года назад +1

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

  • @jora5483
    @jora5483 4 года назад +2

    Great series. Vanillajs tutorials are very few

    • @DevSage
      @DevSage  4 года назад

      Glad you like them!

  • @yinonelbaz5309
    @yinonelbaz5309 2 года назад

    Thank you for this amazing series

  • @riccarrasquilla379
    @riccarrasquilla379 2 года назад

    thanks for the explanation.

  • @spunkyPL
    @spunkyPL 5 лет назад +3

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

  • @botvarma5277
    @botvarma5277 Месяц назад

    thank sir you're amazing 😃

  • @miguelhemmm
    @miguelhemmm 3 года назад +1

    FYI, this is a behavioral pattern

  • @vaneetgupta7189
    @vaneetgupta7189 Год назад

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

  • @preetamvarun9219
    @preetamvarun9219 Год назад

    Thank you

  • @jeanmarcpourchel307
    @jeanmarcpourchel307 4 года назад

    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?

    • @leondaz
      @leondaz 4 года назад +2

      Use classes or learn typescript

    • @matthewmanka8282
      @matthewmanka8282 Год назад

      Definitely use typescript

  • @aaf2011
    @aaf2011 2 года назад

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

  • @matijatu
    @matijatu 4 года назад

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

  • @prabu106
    @prabu106 3 года назад +1

    I know Some java frameworks follows this pattern.

  • @oridubi5844
    @oridubi5844 4 года назад

    Scanner scanner = new Scanner(items);
    while(scanner.hasNext()) {
    System.out.println(scanner.next());
    }