10
you are viewing a single comment's thread
view the rest of the comments
[-] Fisherswamp@programming.dev 3 points 3 weeks ago

Are they eager even with generators?

[-] Dumhuvud@programming.dev 6 points 3 weeks ago

You made me go down the rabbit hole with that question. TIL the very same methods exist on Iterator's prototype. They aren't eager, no.

You can get an iterator out of an array with Array.prototype[Symbol.iterator]() and you can collect an iterator into an array with Iterator.prototype.toArray().

[-] LPThinker@lemmy.world 2 points 3 weeks ago

One reason you may not have known this is that these (iterator methods, not the Iterator itself) are newish additions to Javascript and only available in all the big browsers for just over 1 year.

this post was submitted on 20 Apr 2026
10 points (81.2% liked)

JavaScript

2723 readers
1 users here now

founded 2 years ago
MODERATORS