generator function
Generator 객체를 반환합니다.
function* generator(i) { yield i; yield i + 10; }
*[Symbol.iterator]() { // [Symbol.iterator]: function*()를 짧게 줄임
const iterable1 = {}; iterable1[Symbol.iterator] = function* () { yield 1; yield 2; yield 3; }; console.log([...iterable1]);
const iterable1 = {}; iterable1[Symbol.asyncIterator] = async function* () { yield 1; yield 2; yield 3; }; (async () => { for await (const x of iterable1 ) { console.log(x); // expected output: // "hello" // "async" // "iteration!" } })();

Seonglae Cho