0

I started learning async iterators and could not figure how to store the results in global variables to use them later on.

let arr = [];
(async () => {
  for await (let item of items) {
    console.log(item);
    // arr.push(item)   HOW DO I PUSH THAT INSIDE?   
  }
})()

I declared Symbol.asyncIterator method on the object. Please check codepen https://codepen.io/INR4GE/pen/XWbVxoy?editors=1111 . Dunno why it errors on line 13, in browser it works fine. Please don't ask why am i even doing it this way. It is just for learning purposes

Nick Parsons
  • 45,728
  • 6
  • 46
  • 64
Bobby Fade
  • 47
  • 8

0 Answers0