Monday, December 8, 2025
HomeLanguagesJavascriptJavaScript typedArray.reduceRight() Method

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-

  • 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 reduceRight() function.

Example:

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.reduceRight(sum));
console.log(B.reduceRight(sum));
console.log(C.reduceRight(sum));
console.log(D.reduceRight(sum));


Output:

10
18
9
20
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32429 POSTS0 COMMENTS
Milvus
103 POSTS0 COMMENTS
Nango Kala
6803 POSTS0 COMMENTS
Nicole Veronica
11947 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12015 POSTS0 COMMENTS
Shaida Kate Naidoo
6936 POSTS0 COMMENTS
Ted Musemwa
7190 POSTS0 COMMENTS
Thapelo Manthata
6884 POSTS0 COMMENTS
Umr Jansen
6872 POSTS0 COMMENTS