Built-in values iterator in JavaScript
All iterables have the built-in values
iterator that allows you to iterate over
values. Let's test it on a Map
collection:
javascriptlet map = new Map;
map.set('a', 1);
map.set('b', 2);
map.set('c', 3);
We get an iterator:
javascriptlet iter = map.values();
And loop through it:
javascriptfor (let elem of iter) {
console.log(elem); // 1, 2, 3
}
Задание 1
Test the work of this iterator on an array.
Задание 2
Test the work of this iterator
on a Set collection.