Example 1 — Receiving into yield
next(value) sends in.
JavaScript
function* g() {
const x = yield 1;
yield x;
}
const it = g();
console.log(it.next().value);
console.log(it.next("z").value);How It Works
- First next runs to first yield.
- Second next passes "z" into yield.
