HomeToolsAbout a20k

Yield

What is it

yield operator is used to pause and resume a generator function

function* foo(index) { while (index < 2) { yield index; index++; } } const iterator = foo(0); console.log(iterator.next().value); // 0 console.log(iterator.next().value); // 1 console.log(iterator.next().value); // undefined
© VincentVanKoh