reduceRight()
reduceRight<
T
,R
>(fn
): (initVal
) => (arr
) =>R
Calls the accumulator with each element of the given array, starting with the last element. Returns the final result.
Type Parameters
• T
• R
Parameters
fn
Accumulator
<T
, R
>
The accumulator function to apply to each element of the array.
Returns
Function
Parameters
initVal
R
Returns
Function
Parameters
arr
T
[]
Returns
R
Remark
pure function
Example
reduceRight((total, n) => total - n)(0)([1, 2, 3, 4, 5]);
// -5