JavaScript For Of


The For Of Loop

The JavaScript for of statement goes through the values of an iterable object.

The JavaScript for of statement allows you to go through different types of data structures like Arrays, Strings, Maps, NodeLists and others.

Syntax

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

Variable - In each iteration, the variable takes on the value of the next property. You can declare the variable using const, let or var.

iterable - An object that has iterable properties.


Looping over an Array


Looping over a String


The While Loop

The upcoming chapter will explain the while loop and the do/while loop.