What are JavaScript Generators and Iterators?

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 26

  • @andrew-burgess
    @andrew-burgess  2 місяці тому +9

    By the way, would anyone be interested in a live Q&A? I'm thinking about doing one when we reach 25K subscribers. Lemme know!
    THANKS FOR WATCHING!

    • @obifortune
      @obifortune 2 місяці тому +1

      i would be interested!

  • @hyperprotagonist
    @hyperprotagonist 2 місяці тому +18

    The way you explain things, I feel it always clicks the first time. Watching your video should be valid experience on a CV 😂

  • @DEVDerr
    @DEVDerr 2 місяці тому +14

    Holy shit, probably first breakdown of an iterators that I deeply understood! Gj man!

  • @xeliqa3921
    @xeliqa3921 2 місяці тому +3

    Amazing explanation, easy and clear to understand, especially since you started from ground zero and worked up

  • @anthonylee1309
    @anthonylee1309 2 місяці тому +5

    Thank you for the great vid!

  • @bjul
    @bjul 2 місяці тому +1

    Finally yield makes sense! Thanks a lot 🤝

  • @buscandolaverdad8295
    @buscandolaverdad8295 17 днів тому

    Really cool explanation. Thank you

  • @tefkah
    @tefkah 2 місяці тому +1

    this is great! I've only been comfortable enough with iteratorss etc to be able to consume them, but never enough to actually know what I was doing and definitely not enough to implement them. now I get it, tysm!

  • @fagnersales532
    @fagnersales532 2 місяці тому +1

    Amazing, understood everything you said now I'm excited to find ways to use that in my project.

  • @macr76
    @macr76 2 місяці тому +1

    Great video, I like it. One little nice trick about iterable objects and generators - if you want to convert your object/class into iterable, implemented [Symbol.iterator] method can be generator function, which is far more convenient than writing simple iterable.

    • @andrew-burgess
      @andrew-burgess  2 місяці тому

      Oh, that's a great tip, thanks for sharing!

  • @en818
    @en818 2 місяці тому +1

    thanks! very well explained and super helpful!

  • @quanminh8441
    @quanminh8441 2 місяці тому +1

    I love this so much

  • @frstylol
    @frstylol Місяць тому

    You're THE G🔥🔥

  • @gamingwolf3385
    @gamingwolf3385 2 місяці тому +1

    This is really good , i like your explanation , but what about usecases of those generators , i was waiting for some projects/packages uses them

  • @sayeddileri3461
    @sayeddileri3461 2 місяці тому

    Super helpful. Thanks!

  • @nickolaizein7465
    @nickolaizein7465 2 місяці тому +1

    Very well! Really good. But when do you use generators in your projects? Any good examples of it ?

  • @Luxcium
    @Luxcium Місяць тому

    i would love to been taught about how normal generators can yield promises and the benefit of of such exotic thing when compared to the more normal asyncGenerator that people use normally when they have promises

  • @sanyamjain7058
    @sanyamjain7058 2 місяці тому

    nice explanation and i would like know about "for await...of", async generator, async iterator and async iterable protocols, it confuses me alot..

    • @andrew-burgess
      @andrew-burgess  2 місяці тому

      Thanks! I'm planning to talk about the async versions soon!

  • @adambickford8720
    @adambickford8720 2 місяці тому

    This is why types are nice; you have them in js, you just can't express them. Instead, we reinvent them as 'protocols'.

  • @AK-vx4dy
    @AK-vx4dy 2 місяці тому

    I have a stupid question, is reversing value and done declaration change evalution order and solves problem with do/while loop ?

    • @andrew-burgess
      @andrew-burgess  2 місяці тому

      Not a stupid question! I think you're right. But one thing I got wrong here is returning the final value with done:true. Really, the next result after the final value in the sequence should have value:undefined, done:true.

  • @coder_one
    @coder_one 2 місяці тому

    Great video. We learned what Generators and Iterators are and how to use them in the least useful case in life - writing a function that generates fibbonacci numbers. I completely do not understand why such materials are created....