News for hackers. Stuff that matters.
Re:Ask HN: JS's for-of loop conceptually flawed, or is it ju... by tantalor on Tuesday June 07, 2016 @04:04PM (#11857354)
Store the contents of the generator in memory (an array).

Or make a second instance of the generator.

Re:Ask HN: JS's for-of loop conceptually flawed, or is it ju... by antrion on Tuesday June 07, 2016 @04:16PM (#11857442)
My specific use case was working with 'infinite lists', so the first options is ruled out.

The second option could be a solution, but the specific case was reusing a variable `const nums = iu.iterate(x => x+1, 1)`, and quite extensively. (It's just a helper function to make a list of all natural numbers)

It would be so much nicer if I could just reuse this variable throughout my code