4 ms·
been there. Worst offender I've seen is an eslint rule that forces you to not mutate the object you're creating with reduce() because mutation is bad. So now yo
by deckard1 4y ago
been there. Worst offender I've seen is an eslint rule that forces you to not mutate the object you're creating with reduce() because mutation is bad. So now you're doing object spreading and went from an O(n) algorithm to an O(n^2) algorithm. Wonderful.
There is a lot of unquestioned dogma going around in this industry.
- jvalencia 4y agolol, and then you add an exception for spreading: /* eslint-disable react/jsx-props-no-spreading */
- LAC-Tech 4y agois that an airbnb eslint rule? no wonder their website is so slow!
- cercatrova 4y agoWhy not just use a for loop?
- jcparkyn 4y agoI agree. If your reduce requires mutation, then you almost certainly shouldn't be using reduce.
- dexwiz 4y agoI have pretty much gone back to for loops for anything besides the simplest map()'s. You can get reduce() to do some pretty cool things that always need more lines of comments to explain than a for loop and some variables.
- wiml 4y agoThere's an eslint rule forbidding for loops too.