JavaScript typedArray.reduce() Method Last Updated : 10 Feb, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The typedArray.reduce() is an inbuilt function in JavaScript which is used to reduce each element of the typedArray from left to right into a single value. Syntax: typedArray.reduce(callback) Parameters: It accept a parameter callback function which accept some parameters specified below- previousValue: It is the previously returned value.currentValue: It is the current element being processed in the typedArray. Return value: It returns the result of the reduce() function. Example 1: javascript // Creating some typedArray const A = new Uint8Array([ 1, 2, 3, 4]); const B = new Uint8Array([5, 6, 7]); const C = new Uint8Array([1, 3, 5]); const D = new Uint8Array([2, 4, 6, 8]); // Calling sum() function function sum(previousValue, currentValue) { return previousValue + currentValue; } // Printing reduced value of the given typedArray console.log(A.reduce(sum)); console.log(B.reduce(sum)); console.log(C.reduce(sum)); console.log(D.reduce(sum)); Output: 10 18 9 20 Comment More infoAdvertise with us Next Article JavaScript typedArray.reduce() Method K Kanchan_Ray Follow Improve Article Tags : Misc JavaScript Web Technologies javascript-typedArray JavaScript-Methods +1 More Practice Tags : Misc Similar Reads JavaScript typedArray.reduceRight() Method The typedArray.reduceRight() is an inbuilt function in JavaScript which is used to reduce each element of the typedArray from right to left into a single value. Syntax: typedArray.reduceRight(callback) Parameters: It accept a parameter callback function which accept some parameters specified below- 1 min read JavaScript typedArray.set() Method The typedArray.set() is an inbuilt function in JavaScript which is used to stores a number of values in the given typedArray. typedArray.set(typedArray, offset) Parameters: It accept two parameters which are specified below- typedarray: It is the source array. offset: It is optional and it is into t 1 min read JavaScript typedArray.sort() Method The typedArray.sort() is an inbuilt function in JavaScript which is used to sort the elements of the given typedArray and return the new typedArray with the sorted elements. Syntax: typedArray.sort(); Parameter: It does not accept any parameters. Return value: It returns the new typedArray with the 1 min read JavaScript typedArray.of() Method The typedArray.of() is an inbuilt function in JavaScript which is used to construct a new typedArray with a variable number of parameters. Syntax: TypedArray.of(element0, element1, ......) Parameters: It accepts parameters of different elements whose typedArray is going to be created. Return value: 1 min read JavaScript TypedArray.of() Method The TypedArray.of() method is used to create a new array from a variable number of arguments that are passed to it. Syntax: TypedArray.of( el0, el1, el2, ...elN ) Parameters: This method accepts a variable number of elements, which are used to create the Int16Array array. TypedArray can contain any 2 min read Like