When uses reduce, iteration should be left to right:
[1, 2, 3].reduce((acc, item) => ..., null) - the first item of iteration should be 1, the second - 2, the third - 3.
When uses reduceRight, iteration should be right to left:
[1, 2, 3].reduce((acc, item) => ..., null) - the first item of iteration should be 3, the second - 2, the third - 1.
When uses reduce, iteration should be left to right:
[1, 2, 3].reduce((acc, item) => ..., null)
- the first item of iteration should be1
, the second -2
, the third -3
. When uses reduceRight, iteration should be right to left:[1, 2, 3].reduce((acc, item) => ..., null)
- the first item of iteration should be3
, the second -2
, the third -1
.