Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.
The reduce() method of TypedArray instances executes a user-supplied "reducer" callback function on each element of the typed 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 typed array is a single value. This method has the same algorithm as Array.prototype.reduce().
A function to execute for each element in the typed array. Its return value becomes the value of the accumulator parameter on the next invocation of callbackFn. For the last invocation, the return value becomes the return value of reduce(). The function is called with the following arguments:
accumulatorThe value resulting from the previous call to callbackFn. On the first call, its value is initialValue if the latter is specified; otherwise its value is array[0].
currentValueThe value of the current element. On the first call, its value is array[0] if initialValue is specified; otherwise its value is array[1].
currentIndexThe index position of currentValue in the typed array. On the first call, its value is 0 if initialValue is specified, otherwise 1.
arrayThe typed array reduce() was called upon.
initialValue OptionalA value to which accumulator is initialized the first time the callback is called. If initialValue is specified, callbackFn starts executing with the first value in the typed array as currentValue. If initialValue is not specified, accumulator is initialized to the first value in the typed array, and callbackFn starts executing with the second value in the typed array as currentValue. In this case, if the typed array is empty (so that there's no first value to return as accumulator), an error is thrown.
The value that results from running the "reducer" callback function to completion over the entire typed array.
Thrown if the typed array contains no elements and initialValue is not provided.
See Array.prototype.reduce() for more details. This method is not generic and can only be called on typed array instances.
| ECMAScript® 2027 Language Specification # sec-%typedarray%.prototype.reduce |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 10, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.