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

preview_player
Показать описание
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:

For your reference, check this out:

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
Рекомендации по теме
Комментарии
Автор

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!

nikolajacques
Автор

Fascinating and educational. Thanks for this!

jevforsberg
Автор

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

hansschenker
Автор

Thanks man, learned something new today

Shivs
Автор

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

ahora
Автор

Perfect explanation of not easy issue!

rashidsun
Автор

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)

bengbeng
Автор

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]?

kyleg
Автор

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

jaisah
Автор

Is the iterator object a generator function?

guidoglielmi
Автор

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.

AleksandrStrizhevskiy
Автор

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

wagnerpedroo
Автор

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

keepitplainsimple
Автор

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

SMBLtheGamer
Автор

"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???

RebelMAC
Автор

I am SO confused about the last 2 minutes.

Why is it "new and not "new (<- there's a dot)
It's obviously not "new because we'd land inside the constructor then.
would work i guess, following the example at 3:50, but also only because numbers is an array and already has an iterator. Not because we made one for numList?

But doesn't that mean that numList.numbers['length'] works because length is a "hidden"(hidden to the for loop) value inside the array numbers. testable by:
Thus does NOT point inside the array "numbers" of the object "numList" but rather to the iterator inside the "class" to array.
Now something like const x = new array('a', 'b'); wouldn't work because an array is an inherrent data structure, doesn't need to be constructed and thus doesn't have a cunstructor i guess? But array should still be a class of javascript that stores all the methods like array.push()


I am confused because at 3:20 you said numbers[Symbol.iterator]() is no different to numbers['length']().
Now numbers['length']() wouldn't work anyways only numbers['length'] would... i think, didn't test.
The whole point is that numbers['length'] and numbers[Symbol.iterator]() are inherrently different because:
numbers['length'] points inside the array but
numbers[Symbol.iterator]() points inside the class dealing with arrays

tamikuru
Автор

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.

angelortega
Автор

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

mahamamjad
Автор

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

pencilpopart
Автор

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

mauricioperez