Order of Execution in a For Loop

Christian Hur
1 min readNov 3, 2018

--

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 is not as you see.

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

Java

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

JavaScript/TypeScript

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

PHP

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

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

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

Here’s my video proving it:


My online training courses:

My book “Developing Business Applications for the Web: With HTML, CSS, JSP, PHP, ASP.NET, and JavaScript” is available on Amazon and MC Press.

Check out my author page at http://amazon.com/author/christianhur

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet