Syntax

JavaScript For Loop Syntax

In JavaScript, for loop: loops a set number of times — for (let i = 0; i < 10; i++) { ... }

Quick Answer

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

For Loop

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

Loops a set number of times.

Learn More

How to for loop in JavaScript

  1. Open your JavaScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

JavaScript For Loop Syntax

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

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for for loop?

Use this pattern: for (let i = 0; i < 10; i++) { ... }

Can I copy this JavaScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this JavaScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify