Identifies the type of array elements
The array or array like object of elements to be searched.
A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
Optional
initialValue: T | RIf initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
The value that results from running the "reducer" callback function to completion over the entire array.
The arrReduce() method executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.
The first time that the callback is run there is no "return value of the previous calculation". If supplied, an initial value may be used in its place. Otherwise the array element at index 0 is used as the initial value and iteration starts from the next element (index 1 instead of index 0).
Example