Skip to content

JavaScript for of | Example code

  • by

JavaScript for statement creates a loop iterating over iterable objects. It could use in over iterable data structures such as Arrays, Strings, Maps, sets, and more:

for (variable of iterable) {

JavaScript for of Example

Simple example code.

<!DOCTYPE html>

    const array1 = ['A', 'B', 'C'];

    for (const element of array1) {



JavaScript for of

Looping over a String

    let language = "Tutorial";

    let text = "";
    for (let x of language) {
      text += x;

Output: Tutorial

Do comment if you have any doubts or suggestions on this JS for of statement topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *