codeinabox@programming.dev to JavaScript@programming.devEnglish · 4 个月前Why I don't chain everything in JavaScript anymoreallthingssmitty.comexternal-linkmessage-square13linkfedilinkarrow-up11arrow-down10
arrow-up11arrow-down1external-linkWhy I don't chain everything in JavaScript anymoreallthingssmitty.comcodeinabox@programming.dev to JavaScript@programming.devEnglish · 4 个月前message-square13linkfedilink
minus-squareFisherswamp@programming.devlinkfedilinkarrow-up0·3 个月前Are they eager even with generators?
minus-squareDumhuvud@programming.devlinkfedilinkEnglisharrow-up0·3 个月前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().
minus-squareThinker@lemmy.worldlinkfedilinkarrow-up0·3 个月前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.
Are they eager even with generators?
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().
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.