MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › for...of
for...of - JavaScript | MDN
The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include instances of built-ins such as Array, String, TypedArray, Map, Set, NodeList (and other DOM collections), as well as the arguments object, generators produced ...
W3Schools
w3schools.com › js › js_loop_forof.asp
JavaScript For Of
The JavaScript for of statement loops through the values of an iterable object.
for i++ loop vs. for... of loop. Is there a difference?
The first one is more general, granting you more freedom in how you use the index, how exactly the index is being incremented, etc. The second one is restrictive, being useful for dealing with iterating over collections but closing off some options. Like, for example, if I wanted a loop that swapped the contents of the array around (like a sorting function, as an example), the first one works because I know where I am in the array (index i) and can easily look at its surroundings (i+1 and i-1). The second one just gives me the contents of the current position in the array, but not the position information itself, so I can only deal with a single value at a time. For another example, if I only wanted to deal with even indexes (or treat odd and even differently), the first one lets me change the increment or use if statements to suit my needs. But the second only lets me take the values one at a time and in order, and gives me no inherent way of distinguishing odd/even. Likewise, the first way lets me go backwards from the end to the beginning if I wanted. As for why the first one is used more, even when it isn't required, the answer is a combination of habit, that's what's taught, and it makes it easier if you need to modify the loop's structure. More on reddit.com
Javascript loops: for loop, while loop and do...while loop🔥🖥️
I think that "for in" and "forEach" are too important not to mention. I know it's not the same thing but they are really useful. Also there are really great methods for arrays so you don't have to write your own code, like "filter".
More on reddit.comHelp with for Loop in Javascript
What do you actually mean? A for loop always has the same construct: for( = ; ; ) { // loop body } The loop always runs as long as the yields true and stops on the first false result. If you are talking about something like arr[i] inside the loop, it simply means that you are addressing a single element of an array. arr would be the array, and i the index of the element you want to work with. More on reddit.com
Help understanding for/in loops??
You're trying to see key as a parameter. But it's not a parameter, it's a variable declaration, much like i in your first for loop. You don't have to give it an initial value or increment it or anything though, the runtime does that for you as it iterates over object's properties; all you have to do is consume key. More on reddit.com
Videos
02:50
A Smart Way to Loop Over Arrays - JavaScript For Of in 2 Minutes ...
00:44
What Is A For Of Loop? JavaScript - YouTube
06:57
#28 For...of loop | JavaScript Full Tutorial - YouTube
10:53
#23 JavaScript for..of and for..in Loop | JavaScript for Beginners ...
05:46
How to Write and Use For Loops in JavaScript | Beginner’s Guide ...
07:03
For in and for of loop in javascript - YouTube
Programiz
programiz.com › javascript › for-of
JavaScript for... of Loop
The for..of loop in JavaScript allows you to iterate over iterable objects (arrays, sets, maps, strings etc).
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Loops_and_iteration
Loops and iteration - JavaScript | MDN
A for loop repeats until a specified condition evaluates to false. The JavaScript for loop is similar to the Java and C for loop. ... The initializing expression initialization, if any, is executed. This expression usually initializes one or more loop counters, but the syntax allows an expression ...
Mimo
mimo.org › glossary › javascript › for-loops
JavaScript For Loop: Efficient Iteration in JavaScript
The for of loop simplifies iterating through an arr, making code cleaner. JavaScript's array forEach() method is another form of loop that executes a function once per array element.
W3Schools
w3schools.com › js › js_loop_for.asp
JavaScript for Loop
The for statement creates a loop with 3 optional expressions: for (exp 1; exp 2; exp 3) { // code block to be executed } exp 1 is executed (one time) before the execution of the code block.
Programiz
programiz.com › javascript › for-loop
JavaScript for loop (with Examples)
In JavaScript, the for loop is used for iterating over a block of code a certain number of times, or to iterate over the elements of an array.
DigitalOcean
digitalocean.com › community › tutorials › for-loops-for-of-loops-and-for-in-loops-in-javascript
JavaScript For Loops | DigitalOcean
August 26, 2021 - In this tutorial, we will learn ... elements of the JavaScript programming language. The for statement is a type of loop that will use up to three optional expressions to implement the repeated execution of a code block....
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript for…of loop
Introduction to JavaScript for...of Loop in ES6
October 6, 2023 - let scores = [80, 90, 70]; for (let score of scores) { score = score + 5; console.log(score); }Code language: JavaScript (javascript) ... In this example, the for...of iterates over every element of the scores array. It assigns the element of the scores array to the variable score in each iteration. If you don’t change the variable inside the loop, you should use the const keyword instead of the let keyword as follows:
FlatCoding
flatcoding.com › home › javascript for of loop: syntax and examples
JavaScript for of Loop: Syntax and Examples - FlatCoding
May 8, 2025 - Here is a deeper look at how the for...of loop works behind the scenes: The object must be iterable The loop only works if the object has a built-in method called Symbol.iterator. This method returns an iterator—an object with a next() method. The iterator controls the loop When the loop starts, JavaScript calls iterable[Symbol.iterator]().
GeeksforGeeks
geeksforgeeks.org › javascript › explain-the-differences-between-for-in-and-for-of-statement-in-javascript
Differences Between for-in and for-of Statement in JavaScript - GeeksforGeeks
July 12, 2025 - Conversely, the for..of loop is intended to iterate directly over values in iterable collections like arrays, strings, Maps, or Sets. The JavaScript for-in loops through the enumerable properties of an object.