This section provides a quick description of the 'while' loop statement.
The "while" statement is a very common loop statement in many programming languages.
The JavaScript "while" statement has the following generic syntax format:
while (loop_condition)
statement or statement_block
A "while" statement is executed as follows:
Step 1: "loop_condition" expression is evaluated as a Boolean value.
Step 2: If "loop_condition" is evaluated to "true", continue with Step 4.
Step 3: If "loop_condition" is evaluated to "false", terminate the loop.
Step 4: Execute "statement" or "statement_block".
Step 5: Continue with Step 1.
There is another form of "while" loop, called "do ... while" loop statement,
with the following syntax format:
do
statement or statement_block
while (loop_condition);
"while" loop statement could be executed infinitely, if the "loop_condition" is always evaluated to "true".
A "break" statement could be used inside the loop statement block to terminate the loop early.
A "continue" statement could be used inside the loop statement block to skip the rest of the block
and start the next iteration of the loop.
A tutorial example will be given in the next section showing an example of the "while" loop statement.