for

JavaScript 1.0+, ECMAScript 1.0+, JScript 1.0+ Nav2+, NES2+, IE 3+ Syntax

for( [initial statement;] [condition;] [num;]){

  code;

}

Description

The for keyword is used to create a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a block of statements executed in the loop.

The initial statement is a JavaScript statement or variable declaration. The condition is an optional statement which is evaluated through each iteration of the loop. If condition is satisfied, all statements contained in the loop are executed. num designates if the loop increments or decrements every loop iteration. And finally, the code contains JavaScript statements that are executed each ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.