3
您可以从封闭收益率?ES6/ES2015在封闭收益率内的函数*
// I want the following to work but instead I get:
// Uncaught SyntaxError: missing) after argument list(…)
function* test() {
yield 1;
[2,3].map(x => yield x);
yield 4;
}
var gen = test();
console.log(gen.next().value); // 1
console.log(gen.next().value); // 2
console.log(gen.next().value); // 3
console.log(gen.next().value); // 4
只是不,你不能。 – Bergi
当闭包不是从“内部”(无论何种定义)被调用时,闭包会做什么? – Bergi