Syntax

JavaScript For...of Loop Syntax

In JavaScript, for...of loop: loops over the values of an array or iterable — for (const item of items) { ... }

Quick Answer

Syntax
for (const item of items) { ... }
JavaScriptSyntax

For...of Loop

Code example
for (const item of items) { ... }

Loops over the values of an array or iterable.

Learn More

How to for...of 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...of Loop Syntax

Use for (const item of items) { ... }.

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for for...of loop?

Use this pattern: for (const item of items) { ... }

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