对于ES6生成器,为什么这篇博文的作者说:
来自:http://davidwalsh.name/es6-generators
"第一个下一个(..)调用,我们不发送任何内容.为什么?因为没有收益表达式来接收我们传入的内容."
不是第一次it.next()打电话(yield (x + 1))?
function *foo(x) {
var y = 2 * (yield (x + 1));
var z = yield (y / 3);
return (x + y + z);
}
var it = foo( 5 );
// note: not sending anything into `next()` here
console.log( it.next() ); // { value:6, done:false }
console.log( it.next( 12 ) ); // { value:8, done:false }
console.log( it.next( 13 ) ); // …Run Code Online (Sandbox Code Playgroud)