‹ BackHN Continuity

Thread

Anecdotally, programmers dislike "reduce"

175 points · 283 comments · vinhnx

  1. romellem · · focus · HN ↗
    It is too easy to write O(n^2) code using reduce, in fact I wrote an eslint rule to catch a common pattern I see other developers write.

    - <a href="https:&#x2F;&#x2F;github.com&#x2F;romellem&#x2F;eslint-plugin-no-spread-in-reduce" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;romellem&#x2F;eslint-plugin-no-spread-in-reduc...

    It catches code that looks like this:

        items.reduce((acc, item) =&gt; {
          return {
            ...acc,
            [item.id]: item
          };
        });
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.