Chris Staudinger
Chris Staudinger

@ChrisStaud

8 تغريدة 1 قراءة Dec 07, 2022
📌 Understanding the 5 loops of JavaScript 🧵👇
1.
Loops offer a quick & easy way to do something repeatedly 🚀
The 5 loops in JavaScript essentially do the same thing: — they repeat an action a certain number of times. However, they have important differences 💡
Let’s dive in! ⚡️
JavaScript for loop
Repeats a block of code as long as a certain condition is met.
Typically, used to loop through a block of code a specific amount of times 💡
2. JavaScript while loop
Loops through a block of code as long as the specified condition evaluates to true. As soon as the condition fails, the loop is stopped.
3. JavaScript do…while loop
The do…while loop is a variant of the while loop, which evaluates the condition at the END of each loop iteration.
With a do…while loop the block of code is executed ONCE, and THEN the condition is evaluated 💡
4. JavaScript for…in loop
The for…in loop allows programmers to iterate over the properties of an object ⚡️
5. JavaScript for…of loop
The for…of statement creates a loop Iterating over iterable objects (including Array, String, Set, and so on).
For…in iterates over property names 💡
For…of iterates over property values 💡
That’s a wrap!
If you enjoyed this thread, don’t forget to like, comment, and retweet the first tweet!
I create threads, and hand-drawn illustrations to level up your software development game 🚀 🧵 🎨
Follow @ChrisStaud
for more free tips and free resources.

جاري تحميل الاقتراحات...