Array.reduce_right

Array.reduce_right

Array.reduce_right

Function

Accumulate array elements from right to left.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
callbackFnNoEmptyThe callback signature is fn(acc, value, index, current).
initialAnyNoLast elementInitial accumulated value.

Return value

TypeDescription
AnyReturns the final cumulative value.

Example

Notes

  • An error will be reported when initial is not provided for an empty array.