JavaScript Iterables
Iterables are iterable objects (like Arrays).
Iterables can be accessed with simple and efficient code.
Iterables can be iterated over with for..of loops
The For Of Loop
The JavaScript for..of statement loops
through the elements of an iterable object.
Syntax
for (variable of iterable) {
// code block to be executed
}
Iterating
Iterating is easy to understand.
It simply means looping over a sequence of elements.
Here are some easy examples:
Iterating over a String
Iterating over an Array
Iterating Over a String
You can use a for..of loop to iterate over the elements of a string:
Example
const name = "W3Schools";
for (const x of name) {
// code block to be executed
}
Try it Yourself »
Iterating Over an Array
You can use a for..of loop to iterate over the elements of an Array:
Example
const letters = ["a","b","c"];
for (const x of letters) {
// code block to be executed
}
Try it Yourself »
You can learn more details about Iterables in the chapter
JS Object Iterables.
Iterating Over a Set
You can use a for..of loop to iterate over the elements of a Set:
Example
const letters = new Set(["a","b","c"]);
for (const x of letters) {
// code block to be executed
}
Try it Yourself »
Sets and Maps are covered in the next chapters.
Iterating Over a Map
You can use a for..of loop to iterate over the elements of a Map:
Example
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
for (const x of fruits) {
// code block to be executed
}
Try it Yourself »
★
+1
Reference: https://www.w3schools.com/js/js_iterables.asp
JavaScript Iterables
Re: <t>JavaScript Iterables</t>
Hallo daar! Een kennis uit Antwerpen vertelde me over zijn recente winsten en dat triggerde mij om het ook eens te proberen. Ik belandde op mojabet en was meteen onder de indruk van de overzichtelijke layout van de casino bets. Ik besloot een paar spins te wagen op de slots en tot mijn verbazing pakte ik een mooie bonus. Het is fijn om een plek te vinden in België waar je gewoon eerlijk en plezierig kunt spelen.