for (statement 1; statement 2; statement 3) {
code block to be executed
}
Statement 1 is optional and runs before the start of the loop (code block).
var i = 0;
var length = 10
for (; i < length; i++) {
//The for loop run until i is less than length and you incerement i by 1 each time. javascript doesnt care what you do inside, it just check whether you have variable with name i and length
}
Statement 2 again optionally defines a condition for starting a loop (code block).
var i = 0;
var len = 100;
for (i = 5; ; i++) {
}
Operator 3 is optional and is executed every time after the execution of the cycle (code block).
var i = 0;
var length = 100;
for (; i < length; ) {
}
In a walnut shell, when you have no conditions or initialization, it turns into an endless cycle.
source
share