![]() |
VOOZH | about |
It is an object of Iterables which is also a kind of generalized arrays. Iterables that make any object easier to use in a for..of the loop. We know that arrays are iterative in nature but other than that, there are also several objects which are used for the iterative purpose. Suppose if any object which is not an array but does possess a group of the list, set, etc then for..of can be used to iterate it.
We use for..of loop to represent a range object of any interval. It decides the range in which the for..of the loop will work and iterate the loop.
We will use a method Symbol.iterator (an in-built method in JavaScript) to iterate the range object which is mentioned above. The steps in which this method works:
Syntax:
[Symbol.iterator]
Example:
Output:
2 3 4 5 6 7
Supported Browsers: The browsers supported by Symbol iterator property are listed below:
We have a complete list of Javascript symbols' properties and methods, to check those please go through the Javascript Symbol Complete Reference article.