DEV Community

Cover image for Loops in JavaScript
Jerry L. Glammeier, Jr.
Jerry L. Glammeier, Jr.

Posted on

Loops in JavaScript

While going through the Vets Who Code coding bootcamp we were introduced to loops, mainly for loops. It was not until I completed the cohort and started digging deeper into JavaScript and learning more through books and podcasts that I actually found out there were more to loops that just the for loop. In this article I will be giving an overview of the loops and statements that work with them and how they are used. Maybe in a later article I will dig even deeper into this subject.

While the for loop is used to repeat something until the statement is false, some of the statements used in conjunction with loops are:

continue
do....while
for...in
for...of
labeled
while


The break loop is used to terminate a loop or switch the loop when it is used with a labeled statement.

The Continue loop is used to restart the do...while, for, label and while statements.

The do...while statement repeats until a condition returns false.

The for...in statement through the properties of an object.

The for...of statement through the value of iterable objects.

The label statement utilizes a statement which you can break out of code block with a break statement or a continue statement.

The while statement executes a statement as long as the statement is true.

With this just touching the surface of loops and iterations, it was more than I was aware of or had time to dig into while in the bootcamp. From here on out I just look forward to finding the time to dig deeper into more and more subjects to keep my learning process going.

Top comments (0)