class Class { *[Symbol.iterator]() { yield 1 yield 2 } }
Iterables can be used in for..of statements, and with spread operator:
for
of
for (let x of iterable) console.log(x) console.log([...iterable])
Iterables usage in JavaScript