Loop in JavaScript
- JavaScript loop
-
JavaScript language supports following loops:
While Loop
Syntax
while(<test condition>)
{
// loop body
}
do..while Loop
Syntax
do
{
// loop body
}while(<test condition>);
for loop
Syntax
for (statement 1; statement 2; statement 3)
{
the code block to be executed
}
Various forms of for loop
Syntax
for (statement 1,statement 2; statement3;statement 4)
{
the code block to be executed
}
Various forms of for loop
Syntax
for ( ; statement 2;statement 3)
{
the code block to be executed
}