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:

let map = new Map; map.set('a', 1); map.set('b', 2); map.set('c', 3);

We get an iterator:

let iter = map.values();

And loop through it:

for (let elem of iter) { console.log(elem); // 1, 2, 3 }

Test the work of this iterator on an array.

Test the work of this iterator on a Set collection.

enru