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