tc39 / proposal-joint-iteration

a TC39 proposal to synchronise the advancement of multiple iterators
https://tc39.es/proposal-joint-iteration
66 stars 2 forks source link

What about an extended `for...of` syntax ? #33

Closed yw662 closed 3 weeks ago

yw662 commented 3 weeks ago

Like this:

const foo = [ 1, 2, 3 ]
const bar = [ 4, 5, 6 ]
for (const f, b of foo, bar) {
  console.log(f + b) // 5, 7, 9
}
michaelficarra commented 3 weeks ago

First, this proposal is Stage 2.7 so we're no longer making any changes of this sort.

Second, this doesn't seem much better than the alternative

for (const [f, b] of Iterator.zip(foo, bar)) {
  console.log(f + b) // 5, 7, 9
}