I was for quite some time under the impression that a for
loop could exist solely in the following format:
for (INITIALIZER; STOP CONDITION
Syntax of for loop is:
for (pre-block; condition; post-loop-block)
loop-block;
First, pre-block is executed, various variables are defined.
In each loop:
this goes all the way back to C syntax - from which javascript has stole a bunch. the main trick is the comma-operator which seems to appear in almost no other place except for loops
The first clause initializes any variables you want to use. The second clause is indeed the stop condition. The third clause includes any logic to be executed at the end of each iteration. Multiple statements can be separated by commas.