bhylu.com

Advertisements

JS Loops

Use for...of to read iterable values. Use Object.entries when you need an ordinary object as name-value pairs.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const tools = ["Brush", "Tape"];
for (const tool of tools) {
  console.log(tool);
}

What happens

The loop reads each tool value in order.