Home >> Javascript >> For loop in Javascript

For loop in Javascript

The for loop a block of code for certain number of times.

Syntax

for(initialization; condition; increment){
    // code to be executed
}

Example

for(i=1;i<=5;i++){
     document.write(i+"<br>");
}

Output

1

2

3

4

5

Post Your Comment

Next Questions
While loop
Do while loop
Functions
Objects
Array
Events
Onchange event
Onclick event
Onmouseover event
Onmouseout
Onkeydown event
Onload event

Copyright ©2022 coderraj.com. All Rights Reserved.