Order of Execution in a For Loop

The For Loop is not only the most important and widely used loop in all modern computer languages, but perhaps the most cleverly invented. The only thing that’s a little confusing for the novice programmer is that the order of execution (or flow of control) happens in a particular order worth exploring.

Here’s the typical syntax for a few C-based derivative languages:

Java

for(int i=0; i<10; i++){
    // Statements
}

JavaScript/TypeScript

for(let i=0; i<10; i++){
    // Statements
}

PHP

for($i = 0; $i<10; $i++){
    // Statements
}

The steps in order of execution in a FOR LOOP are:

for ( step 1step 2step 4){
  step 3 
}

Here’s my video proving it: