Switch to Dark Mode

JavaScript | Advanced JavaScript | Question 7

Last Updated : Jan 13, 2025
Discuss
Comments

What will the following generator function output?

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


A

1

B

2

C

undefined

D

Error

Share your thoughts in the comments