JS: Iterator.concat

By Xah Lee. Date: .
Iterator.concat(iterable_1, iterable_2, etc)

arguments are Iterable Objects.

creates a new Iterator object that joins the yields of given arguments.

if you want to join iterators, use first Iterator.from .

// join the iterators in iterables, into a new iterator
const xx = Iterator.concat(
 [1, 2],
 new String("abc"),
 new Set([3, 4]),
 new Map([["a", 1], ["b", 2]]),
);

console.log(xx);
// Object [Iterator Helper] {}

// convert the new iterator to array to print their values
console.log(Array.from(xx));
// [ 1, 2, "a", "b", "c", 3, 4, [ "a", 1 ], [ "b", 2 ] ]