Learn Scripting Languages from the Master!
Looping or iteration control is used to execute some set of instructions repeatedly. Without loops, we would have to write the instructions as many times we want them to execute. Let's print numbers 1 through 5 without using a loop:
<script language="javascript">document.write (1 + "<br>");document.write (2 + "<br>");document.write (3 + "<br>");document.write (4 + "<br>");document.write (5 + "<br>");</script>
The following shows the output of the above code:
Before we do this same example with a loop control structure, let's first point out that there are two types of loops:
Please access the following pages for more information about JavaScript loop control structures: