CodesJava

Easy learning with example program codes

TypedArray reduceRight() JavaScript

The Javascript TypedArray reduceRight() method is used to reduce the elements of an array (from right-to-left) into a single value.

Syntax:

array.reduceRight(function(total, currentValue, index, arr), initialValue)

Parameters:
total: It represents previously returned value of the function.
currentValue: It represents the index position of current element.
index: It represents the index position of current element.
arr: It represents the array.
initialValue: It represents the initial value passed to the function.

Returns:
It returns the reduced single value.

Example:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">   
var Jewels = ["DIAMOND","GOLD","PLATINUM","SILVER"];
let result =Jewels.reduceRight(function(a,b)  
{  return a + b;  });   
document.write(result);  
</script>
</body>
</html>

Output:

SILVERPLATINUMGOLDDIAMOND
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status