• metiulekm@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    10
    ·
    4 months ago

    Same in Python, Rust, Haskell and probably many others.

    But apparently JS does work that way, that is its filter always iterates over everything and returns a new array and not some iterator object.

    • nous
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      4 months ago

      The old methods on Array will eagerly evaluate all elements. But JS has a new Iterator type with methods that works lazily instead.