- Diwali Online Shopping Scams 2026: 10 Ways to Stay Safe
- 10 Best DDoS Protection Services for 2027
- 12 Best Web Application Firewalls (WAF) for 2027
- Best Ethical Hacking Tools in 2027: Free & Paid Picks
- Software supply chain attacks 2026: Timeline and developer checklist
- Binance Hack: $6.3 Billion Drained in the Largest Crypto Theft Ever. What We Know So Far
- This Site Uses XSLT Chrome Warning Explained: How to Fix It
- iPad mini OLED Price in India: Wi-Fi & Cellular Variants, Offers
A for...of Loop is a control flow statement that creates a loop iterating over iterable objects, including built-in String, Array, array-like objects (e.g., arguments or NodeList), TypedArray, Map, Set, and user-defined iterables.
Syntax of a for…of Loop
The syntax of a for...of Loop in JavaScript is as follows:
for (variable of iterable) {
// code to be executed
}
- Variable: On each iteration, a different property value is assigned to the variable.
- Iterable: This is an object whose enumerable properties are iterated.
Example of a for…of Loop
Here’s a simple example of a for...of Loop that prints the elements of an array:
let fruits = ["apple", "banana", "mango"];
for (let fruit of fruits) {
console.log(fruit);
}
In this example, the for...of Loop iterates over the elements of the fruits array and print each fruit.
The for...of Loop is a unique and powerful tool in JavaScript, allowing you to easily iterate over the elements of iterable objects. It’s a fundamental concept that’s widely used in programming, so understanding how it works will greatly enhance your JavaScript coding skills.



