JavaScript supports the standard loop constructs you have seen in other programming languages:
In a do-while loop, the loop’s body is executed once, and then, if the condition holds, the program returns to the top of the block.
When it comes to counter-controlled loops (when we know exactly how many iterations we need, e.g. when we go over the elements of an array), the for loop provides a more compact syntax:
You can cram in multiple variables, update expressions:
The while and do-while loops are best for event-controlled loops (when the number of iterations is unknown before runtime, e.g., when we read data from a file and don’t know how many lines or how many values are there).
break & continue
The break statement exits out of a loop, while the continue statement will skip to the next iteration:
for..of loop
The for..of loops are used for looping through iterable objects such as arrays.