JavaScript | Advanced JavaScript | Question 7

Last Updated :
Discuss
Comments

What will the following generator function output?

JavaScript
function* generator() {
    yield 1;
    yield 2;
    yield 3;
}
const gen = generator();
console.log(gen.next().value);


1

2

undefined

Error

Share your thoughts in the comments