How To Use Iterators in JavaScript - Iterate Over Arrays and Collections

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ส.ค. 2019
  • In this video I'll be showing you how to use and create iterators in JavaScript - you can use them to iterate over a collection or data structure.
    Support me on Patreon:
    / dcode - with enough funding I plan to develop a website of some sort with a new developer experience!
    For your reference, check this out:
    developer.mozilla.org/en/docs...
    Follow me on Twitter @dcodeyt!
    If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
    #javascript #web #development

ความคิดเห็น • 38

  • @nikolajacques5982
    @nikolajacques5982 3 ปีที่แล้ว +17

    Not an easy topic. After struggling with it and making it out on the other side, it seems clear to me that a lot of thought was put into making this tutorial. Thanks!

  • @jevforsberg4766
    @jevforsberg4766 2 ปีที่แล้ว +3

    Fascinating and educational. Thanks for this!

  • @DanielZotti
    @DanielZotti 3 ปีที่แล้ว +3

    Nice and clean explanation!

  • @hansschenker
    @hansschenker 2 ปีที่แล้ว

    finally understood Iterator! Thank's a lot for publishing!

  • @honeypot11
    @honeypot11 11 หลายเดือนก่อน

    the BEST video on this topic imo

  • @gauravsrivastav9648
    @gauravsrivastav9648 3 ปีที่แล้ว

    Very good explanation mate

  • @rashidsun
    @rashidsun 3 ปีที่แล้ว

    Perfect explanation of not easy issue!

  • @ahora1026
    @ahora1026 5 ปีที่แล้ว +3

    I'm first? Wow. Even though I know about iterators it's nice to listen!

  • @bengbeng2005
    @bengbeng2005 2 ปีที่แล้ว

    waw, your way of explaining things is very impressive, you make things easier, thank you. (by the way, are you from Africa because your accent sounds like one)

  • @wagnerpedroo
    @wagnerpedroo ปีที่แล้ว

    foi simples sua explicação, mas uma pergunta que tenho é: como posso usar o iterador na prática

  • @mertarslan7269
    @mertarslan7269 2 ปีที่แล้ว

    best video

  • @kyleg6790
    @kyleg6790 4 ปีที่แล้ว +2

    Thanks for this. Can you explain what you mean when you say numbers[Symbol.iterator]() is the same as numbers["length"]()? Do you mean numbers[i]?

    • @yokunjon
      @yokunjon 3 ปีที่แล้ว +1

      Well, that means it is one of object properties, so you can access it as you access length.

  • @jeanclaudecamara9505
    @jeanclaudecamara9505 ปีที่แล้ว

    Nice❤

  • @AleksandrStrizhevskiy
    @AleksandrStrizhevskiy ปีที่แล้ว

    I am getting an error: cannot read properties of undefined. I will just loop differently through the data structure but it is strange that in your video the system goes through the undefined value without a problem but I get an error.

  • @guidoglielmi7992
    @guidoglielmi7992 2 ปีที่แล้ว

    Is the iterator object a generator function?

  • @jaisah510
    @jaisah510 3 ปีที่แล้ว +2

    Your keyboard made more noise then you😅
    Btw nice explanation.

  • @totfosk
    @totfosk ปีที่แล้ว

    just WOW

  • @SMBLtheGamer
    @SMBLtheGamer 5 ปีที่แล้ว +2

    I thought iterators were just the regular "for loops, apparently JavaScript finally has a for each loop like function.

  • @keepitplainsimple1466
    @keepitplainsimple1466 3 ปีที่แล้ว +2

    You explained it really nice
    But I didn't get it completely 😅

  • @tamikuru7936
    @tamikuru7936 2 ปีที่แล้ว

    I am SO confused about the last 2 minutes.
    Why is it "new numberList()[Symbol.iterator]()" and not "new numberList().[Symbol.iterator]()"? (

  • @Rebel8MAC
    @Rebel8MAC 3 ปีที่แล้ว +3

    "so, you might be quite impressed with how it works, but also a bit curious..."....
    No, I'm curious about WHY it exists. It seems like extra complexity and typing for going through a for loop? Why would I even use this???

    • @bidabida1399
      @bidabida1399 2 ปีที่แล้ว

      iterator explains how loop like for-each iterate over data structures

    • @miggu
      @miggu 9 หลายเดือนก่อน

      Seemingly it's like inventing the wheel, however ..... consider it as the foundation of how iterable data composites work in javascript, it's how things work, not what you must necessarily use. Create an array in the console, check the prototype of that array, now : arr.__proto__[Symbol.iterator]() , yes return a function from that function, and inspect it. It exists because it's how it was conceived to work , would you ever use it? I doubt it.

    • @sekemilo
      @sekemilo 3 หลายเดือนก่อน

      Exactly my concern but @miggu has given a satisfying answer

  • @angelortega4
    @angelortega4 4 ปีที่แล้ว

    Hi, excuse me, do you have any video where they teach
    how to import a csv file and display the data in an html table?
    to then be stored in a database.
    In java.
    Greetings.

  • @isi1044
    @isi1044 ปีที่แล้ว

    whats the point of an Iterators?

  • @mahamamjad1739
    @mahamamjad1739 3 ปีที่แล้ว

    You said "ITERATOR" and I heard "CINDERALLA".

  • @mauricioperez3645
    @mauricioperez3645 ปีที่แล้ว

    why all code courses have this annoying keyboard click always so loud, it's a big distraction.

  • @pencilpopart
    @pencilpopart 4 ปีที่แล้ว +4

    I deem this video completely unhelpful, because after 10 minutes I still didn't understand a word of it.

    • @thejewelershand
      @thejewelershand 3 ปีที่แล้ว +3

      For me it was perfect

    • @Rebel8MAC
      @Rebel8MAC 3 ปีที่แล้ว

      It seems to be a pattern for almost all coders fall into; they try to teach code to beginners but they explain things as if the person watching already knows many of the concepts of code and even thinks like a coder. So a lot of the videos are missing context for beginners and we can't even start because we dont have the right software or file not pointing to the correct location but we don't even know it's wrong because they skipped over that part. It's frustrating but I'm sure it's unintentional but it's weird how it in happens almost exclusively in the field of coding.

    • @bengbeng2005
      @bengbeng2005 2 ปีที่แล้ว +1

      @@Rebel8MAC I found this tutorial the best one that explains iterator, his way of teaching is very good, and yes most tutorials on youtube assume you have some programming background, but you can find books that go from scratch

  • @itsnobledean9450
    @itsnobledean9450 10 หลายเดือนก่อน

    To me, he's just all over the place with his explanations. This is not the video for me. I was confused up until I left.