Statements and declarations

for statement

Try the free JavaScript compiler

Runs initialization once, then repeats test, body and update. An initial falsy test skips the body; a continue targeting this loop still runs its update before testing.

Formal Syntax & Structure

javascript syntaxjavascript
for (initialization; test; update) { body }

Working Example

Example Snippetjavascript
for (let i = 0; i < 3; i++) { console.log(i); }
JavaScript Reference