0% found this document useful (0 votes)
20 views

Loops

Uploaded by

sujiithsivakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Loops

Uploaded by

sujiithsivakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Loops

Loops

for statement
do...while statement
while statement
break statement
continue statement
for...in statement
for...of statement
for statement

A for loop repeats until a specified condition


evaluates to false.
for ([initialExpression]; [conditionExpression];
[incrementExpression])
statement
do...while statement

The do...while statement repeats until a specified


condition evaluates to false.

A do...while statement looks as follows:

do
statement
while (condition);
while statement

A while statement executes its statements as long as


a specified condition evaluates to true.
A while statement looks as follows:

while (condition)
statement
break statement

Use the break statement to terminate a loop, switch,


or in conjunction with a labeled statement.
The syntax of the break statement looks like this:

break;
continue statement

The continue statement can be used to restart


a while, do-while or for.
for...in statement

The for...in statement iterates a specified variable


over all the enumerable properties of an object. For
each distinct property, JavaScript executes the
specified statements. A for...in statement looks as
follows:

for (variable in object)


statement
for...of statement

The for...of statement creates a loop Iterating over


iterable objects

for (variable of object)


statement
Difference between for…in and for...of

While for...in iterates over property names, for...of


iterates over property values:

You might also like