At times, certain instructions require repeated execution. Loops are an ideal way to do the same. A loop represents a set of instructions that must be repeated. In a loop’s context, a repetition is termed as an iteration.
No | Loop & Description |
1 | for loopThe for loop is an implementation of a definite loop. The for loop executes the code block for a specified number of times. It can be used to iterate over a fixed set of values, such as an array |
2 | for…in LoopThe for...in loop is used to loop through an object's properties. |
No | Loop & Description |
1 | while LoopThe while loop executes the instructions each time the condition specified evaluates to true. In other words, the loop evaluates the condition before the block of code is executed. |
2 | do…while LoopThe do…while loop is similar to the while loop except that the do...while loop doesn’t evaluate the condition for the first time the loop executes. |