InterviewQuestions icon indicating copy to clipboard operation
InterviewQuestions copied to clipboard

《简述一下 Generator 函数》这篇里实例的结果有点小问题

Open CatherineYF opened this issue 4 years ago • 0 comments

function* gen(x) {
  var y = yield x + 2;
  return y;
}

var g = gen(1);
g.next() 
g.next(2) //  这里的结果是return返回的,done应该是true

CatherineYF avatar Jul 04 '21 00:07 CatherineYF