Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript | typedArray.reduceRight() with Examples

  • Last Updated : 31 Jul, 2018

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.


Parameters: It accept a parameter callback function which accept some parameters specified below-

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

  • 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.

JavaScript code to show the working of this function:

Code #1:

  // 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
  document.write(A.reduceRight(sum) +"<br>");
  document.write(B.reduceRight(sum) +"<br>");
  document.write(C.reduceRight(sum) +"<br>");


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!