Master JavaScript.
- Topic 7
Looping Explained: 🧵
- Topic 7
Looping Explained: 🧵
- For
- loops through a block of code a number of times.
- Executes the loop block for a specified number of times under a termination condition.
- loops through a block of code a number of times.
- Executes the loop block for a specified number of times under a termination condition.
- For in loop
- loops through the properties of an object.
- loops through the properties of an object.
1. A `while` loop evaluates the condition inside the parenthesis ().
2. If the condition evaluates to `true`, the code inside the `while` loop is executed.
3. The condition is evaluated again.
2. If the condition evaluates to `true`, the code inside the `while` loop is executed.
3. The condition is evaluated again.
4. This process continues until the condition is `false`.
5. When the condition evaluates to `false`, the loop stops.
5. When the condition evaluates to `false`, the loop stops.
1. The body of the loop is executed at first. Then the condition is evaluated.
2. If the condition evaluates to `true`, the body of the loop inside the `do` statement is executed again.
3. The condition is evaluated once again.
2. If the condition evaluates to `true`, the body of the loop inside the `do` statement is executed again.
3. The condition is evaluated once again.
4. If the condition evaluates to `true`, the body of the loop inside the `do` statement is executed again.
5. This process continues until the condition evaluates to `false`. Then the loop stops.
5. This process continues until the condition evaluates to `false`. Then the loop stops.
If you found this thread useful,
1. Do Retweet the first tweet.
2. Follow @CodeMarch
for the amazing content on Javascript & React.
1. Do Retweet the first tweet.
2. Follow @CodeMarch
for the amazing content on Javascript & React.
جاري تحميل الاقتراحات...