Hacker News new | ask | show | jobs
by recursivedoubts 64 days ago
the intermediate objects are still created, they just aren't given names/saved to a specific memory location somewhere

do you mean like streaming APIs where intermediate data structures aren't created? Is that what javascript does w/map() etc?

1 comments

> the intermediate objects are still created

Yeah; this is what the new iterator methods were intended to solve

https://x.com/MozDevNet/status/2029527411424219254

Basically?

  // This type of usage creates intermediates
  array.map().filter()
  // But these would not?
  array.values().map().filter().toArray()
  array.values().reduce()
unfortunately iterators have their own set of overheads and it's not clear that these new methods are any faster for most use cases.