April 2018
Beginner
536 pages
13h 21m
English
In JavaScript, some built-in types are built-in iterables with a default iteration behavior. To be an iterable, an object must implement the @@iterator method, meaning that the object (or one of the objects in its prototype chain) must have a property with a @@iterator key, which is available via constant Symbol.iterator.
The for...of statement creates a loop iterating over iterable objects (including array, map, set, string, arguments object, and so on):
let iterable = [10, 20, 30];
for (let value of iterable) {
value += 1;
console.log(value);
}