Javatpoint Logo
Javatpoint Logo

JavaScript TypedArray reduce() Method

The JavaScript reduce() method reduces the elements of an array into a single value and the returned value of the function is stored in an accumulator and each element in the array (from left to right) has to reduce it to a single value.

Note: Calling reduce() on an empty array without an initial value is an error.



Total(required): The previously returned value of the function.

CurrentValue(Required): The value of the current element.

Index(Optional): The index of the current element being processed in the array. Starts at index 0.

Arr(Optional): The array reduce() was called upon.

InitialValue(Optional): A value to be passed to the function as the initial value.

Return value:

Return the reduced single value of the array.

Browser Support:

Chrome Yes
Safari 4
Firefox 3.0
Opera 10.5

Example 1

JavaScript reduce() Method

Test it Now



Example 2

JavaScript reduce(initialValue) Method

Test it Now



Example 3

JavaScript reduce() Method

Test it Now


Java, MongoDB, python, C, RDBMS, C++

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA