Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 682 Bytes

File metadata and controls

25 lines (19 loc) · 682 Bytes

JavaScript for...of Loop README

Description

The for...of loop in JavaScript is used to iterate over iterable objects, such as arrays, strings, maps, sets, and more. It provides a concise and readable syntax for iterating through the elements of a collection.

Syntax

for (variable of iterable) {
  // code to be executed
}

variable: A variable to represent the current element of the iterable in each iteration.
iterable: The object or array-like structure to be iterated over.

Example

Iterating over an Array

const numbers = [1, 2, 3, 4, 5];

for (const number of numbers) {
  console.log(number);
}