▲ 10 ▼ Why I don't chain everything in JavaScript anymore (allthingssmitty.com) submitted 3 months ago by codeinabox@programming.dev to c/javascript@programming.dev 13 comments fedilink hide all child comments
[–] Fisherswamp@programming.dev 3 points 3 months ago (1 child) Are they eager even with generators? permalink fedilink source parent hideshow 2 child comments replies: [–] Dumhuvud@programming.dev 6 points 3 months ago (1 child) 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(). permalink fedilink source parent hideshow 2 child comments replies: [–] LPThinker@lemmy.world 2 points 3 months 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. permalink fedilink source parent
[–] Dumhuvud@programming.dev 6 points 3 months ago (1 child) 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(). permalink fedilink source parent hideshow 2 child comments replies: [–] LPThinker@lemmy.world 2 points 3 months 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. permalink fedilink source parent
[–] LPThinker@lemmy.world 2 points 3 months 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. permalink fedilink source parent