Do you know what does array
reduce
It's actually the JavaScript array reduce
function rather than being something specific to TypeScript.
As described in the docs: Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value.
Here's a TypeScript example which sums up the values of an array:
total = [0, 1, 2, 3].reduce((a, b) => a + b);
alert(total);
The alert
box will show 6
.