Skip to content

unicorn/no-array-reduce Restriction ​

What it does ​

Disallow Array#reduce() and Array#reduceRight().

Why is this bad? ​

Array#reduce() and Array#reduceRight() usually result in hard-to-read and less performant code. In almost every case, it can be replaced by .map, .filter, or a for-of loop.

It's only somewhat useful in the rare case of summing up numbers, which is allowed by default.

Example ​

javascript
array.reduce(reducer, initialValue);
array.reduceRight(reducer, initialValue);

References ​

Released under the MIT License.