This solution is generated by ChatGPT, correctness is not guaranteed. You might also be able to find a solution fromcommunity posts.
AI solution for JavaScript Quiz on BFE.dev
110. yield
The code will output the following by console.log:
[1, 2, 3]
1
genA
is a generator function that uses yield
to return an array [1, 2, 3]
as a single value.
genB
is another generator function that uses yield*
to delegate to the iterable [1, 2, 3]
. This means that each value in the iterable is yielded individually, rather than as a single array.
So when we call genA().next().value
, we get the first (and only) value in the array [1, 2, 3]
.
When we call genB().next().value
, we get the first value in the iterable [1, 2, 3]
, which is 1
.