Iterator Invocation in JavaScript

Each sequential call of the iterator should return an object of a special structure. Let's examine it. Let's say we have an array:

javascriptlet arr = [1, 2, 3];

Let's get the array iterator into a variable:

javascriptlet iter = arr[Symbol.iterator]();

Now this variable contains an object with a method next. This method will return an object with a key value, containing the value of the element, and a key done, containing information about whether the iteration has finished or not:

javascriptconsole.log( iter.next() ); // {value: 1, done: false}

Sequential calls of the next method will yield the next element each time:

javascriptconsole.log( iter.next() ); // {value: 1, done: false}
console.log( iter.next() ); // {value: 2, done: false}
console.log( iter.next() ); // {value: 3, done: false}

And as soon as the elements run out, we will see the following values:

javascriptconsole.log( iter.next() ); // {value: undefined, done: true}
Задание 1

Get the iterator of the Map collection. Call it sequentially until the collection elements are exhausted.

Задание 2

Get the iterator of the NodeList collection. Call it sequentially until the collection elements are exhausted.

Задание 3

Get the iterator of the HTMLCollection collection. Call it sequentially until the collection elements are exhausted.