Generators 2
completion record
function* gen() {
try {
yield 1
yield 3
} finally {
yield 4
}
}
// 4
iterator closing
for (let smth of someGen()) {
if (...)
break // итератор должен закрыться и вызваться метод return
}
function* gen() {
yield* [1, 2, 3]
}
[...gen()] // [1, 2, 3]
function* gen2() {
yield [1, 2, 3]
}
[...gen2()] // [[1, 2, 3]]
Async/await (stage3)
let all = (...args) => Promise.all(args)
async () => {
let [aR, bR, cR] = await all(a,b,c)
}