12.2.2 제너레이터와 return
제너레이터에서는 return을 쓸 때 반환값을 쓰지 않는 습관을 들이는 것을 권장
function* abc() {
yield 'a';
yield 'b';
return 'c';
}
const iter = abc();
iter.next(); // {value: "a", done: false}
iter.next(); // {value: "b", done: false}
iter.next(); // {value: "c", done: false}
for (let l of abc())
console.log(l); // c 출력 안됌Last updated