The task is to convert an iterator into an array
This can be performed by iterating each value of the iterator and storing the value into another array
To make an iterator for an array:
const it = array[Symbol.iterator]();
So first we make an iterator for the “array” named “it”. After creating the iterator we iterate to each value stored in that iterator and push it in another array named “p” with the use of the following code
where the word is the value corresponding to the array elements stored in the iterator. After iterating through each of the element we get our final array where all the values of the iterator get stored in p.
[object Array Iterator] After the coversion the array becomes ["Geeks", "for", "Geeks"]
- CSS | transform-origin Property
- CSS text-transform Property
- CSS | transform Property
- HTML | DOM Style transform Property
- CSS | transform-style Property
- HTML | canvas transform() Method
- How to apply multiple transform property to an element using CSS ?
- Node.js | Stream transform.destroy() Method
- Collect.js | transform() Function
- D3.js zoom.transform() Function
- D3.js transform.toString() Function
- Lodash _.transform() Method
- ArrayList iterator() method in Java with Examples
- ConcurrentLinkedDeque iterator() method in Java with Example
- DelayQueue iterator() method in Java with Examples
- Vector iterator() method in Java with Examples
- Difference between an Iterator and ListIterator in Java
- Difference between Iterator and Enumeration in Java with Examples
- Lodash _.prototype[Symbol.iterator]() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.