It is an ECMA5 function.

It is use to reduce the array to a single value by performing certain operation in the callback function.
In simple terms callback function will be called for all the elements in the array.

Call signature

array.reduce(function(total, currentValue, currentIndex, arr), initialValue)

total – is the processed value in each iteration
currentValue – current array element in the iteration
InitialValue – Initial value of total if needed

More on Medium

Leave a Reply