Making an object iterable in JavaScript

obj = {}
obj[Symbol.iterator] = function* () {
    yield 1
    yield 2
}

Iterables can be used in for..of statements, and with spread operator:

for (let x of iterable) console.log(x)
console.log([...iterable])

Iterables usage in JavaScript