• mcv@lemmy.zip
    link
    fedilink
    arrow-up
    4
    ·
    6 days ago

    Absolutely. I’ve used many reduces that I later regretted. It’s powerful, but also too cryptic.

    And reduce has hidden performance risks. I’ve seen reduce used where the collector was assembled with a spread operator. But that’s a loop within a loop, and can get very expensive. A simple forEach loop and just appending the new value in old fashioned ugly pedestrian imperative code, does not carry that risk.