DEV Community

Play Button Pause Button
Harit Himanshu
Harit Himanshu

Posted on

Everything about for loops in JavaScript?

Learn about the most common ways of using a for loop in JavaScript. In this video we will cover for, for..in, and for..of loops in JavaScript.

Find the code samples at https://gist.github.com/SuperBonsaii/...

You will learn how to iterate on numbers, Strings, Arrays, Set and Objects in JavaScript using for loops

Harit on Twitter: https://twitter.com/harittweets

Subscribe for moe videos on JavaScript with Visualization: https://www.youtube.com/channel/UC0yZ...
Follow bonsaiilabs on Twitter: https://twitter.com/bonsaiilabs
Follow bonsaiilabs on Facebook: https://www.facebook.com/thebonsaiilabs
Visit bonsaiilabs at https://bonsaiilabs.com

Top comments (4)

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

While loops don't get any love in modern JavaScript 😒

Collapse
 
harittweets profile image
Harit Himanshu

Adam, yeah. Personally, I also tend to use map, reduce and filter a lot more since the iteration comes baked in!
I am working on getting the videos on them out in the near future!

Collapse
 
art4coding profile image
Ryan Tao Spencer

Can i use this to iterate over;
An array like object such as;
document.getElementsByClassName('something')[?];

to add an event listener to all nodes?
i tried [*] but it didn't do anything.

Collapse
 
harittweets profile image
Harit Himanshu

Could you please paste the code you have tried and what expected output you are looking for?