The for and for-in loops
In this lesson, you will have an overview of all flow-control statements provided by the JavaScript language.
We'll cover the following...
We'll cover the following...
The for Loop
Just as in many programming languages, the for loop provides a pretest with optional variable initialization and optional post-loop code to be executed:
Illustration #
Here is an illustration to explain the above concept
Syntax #
The syntax of the for loop in JavaScript is as follows:
Example #
This example shows the usage of a for loop:
The initialization, condition, and post_loop_expression are all optional, so you can create an infinite loop by omitting all of them:
...