
- ES6 - Home
- ES6 - Overview
- ES6 - Environment
- ES6 - Syntax
- ES6 - Variables
- ES6 - Operators
- ES6 - Decision Making
- ES6 - Loops
- ES6 - Functions
- ES6 - Events
- ES6 - Cookies
- ES6 - Page Redirect
- ES6 - Dialog Boxes
- ES6 - Void Keyword
- ES6 - Page Printing
- ES6 - Objects
- ES6 - Number
- ES6 - Boolean
- ES6 - Strings
- ES6 - Symbol
- ES6 - New String Methods
- ES6 - Arrays
- ES6 - Date
- ES6 - Math
- ES6 - RegExp
- ES6 - HTML DOM
- ES6 - Iterator
- ES6 - Collections
- ES6 - Classes
- ES6 - Maps And Sets
- ES6 - Promises
- ES6 - Modules
- ES6 - Error Handling
- ES6 - Object Extensions
- ES6 - Reflect API
- ES6 - Proxy API
- ES6 - Validations
- ES6 - Animation
- ES6 - Multimedia
- ES6 - Debugging
- ES6 - Image Map
- ES6 - Browsers
- ES7 - New Features
- ES8 - New Features
- ES9 - New Features
- ES6 Useful Resources
- ES6 - Quick Guide
- ES6 - Useful Resources
- ES6 - Discussion
ES6 - Loops
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 loops context, a repetition is termed as an iteration.
The following figure illustrates the classification of loops −

Definite Loop
A loop whose number of iterations are definite/fixed is termed as a definite loop. The for loop is an implementation of a definite loop.
for (initial_count_value; termination-condition; step) { //statements }
Sr.No | Definite Loop & Description |
---|---|
1 |
The for loop
The for loop executes the code block for a specified number of times. |
2 |
The forin loop
The for...in loop is used to loop through an object's properties. |
3 |
The forof loop
The forof loop is used to iterate iterables instead of object literals. |
Indefinite Loop
An indefinite loop is used when the number of iterations in a loop is indeterminate or unknown.
Indefinite loops can be implemented using −
Sr.No | Indefinite Loop & Description |
---|---|
1 |
The while loop
The while loop executes the instructions each time the condition specified evaluates to true. |
2 |
The dowhile loop
The dowhile loop is similar to the while loop except that the do...while loop doesnt evaluate the condition for the first time the loop executes. |
The Loop Control Statements
Sr.No | Loop Control Statements & Description |
---|---|
1 |
The break statement
The break statement is used to take the control out of a construct. |
2 |
The continue statement
The continue statement skips the subsequent statements in the current iteration and takes the control back to the beginning of the loop. |
Using Labels to Control the Flow
A label is simply an identifier followed by a colon (:) that is applied to a statement or a block of code. A label can be used with break and continue to control the flow more precisely.
Line breaks are not allowed between the continue or break statement and its label name. Also, there should not be any other statement in between a label name and an associated loop
Sr.No | Label & Description |
---|---|
1 |
Label with Break
A label can be used with break and continue to control the flow more precisely. |
2 |
Label with Continue
Line breaks are not allowed between the continue or break statement and its label name. |