C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript TypedArray reduceRight() Method.The JavaScript reduceRight() method reduces the elements of an array into a single value and the returned value of the function is stored in an accumulator and each element in the array (from right-to-left) has to reduce it to a single value. Note: Calling reduceRight()on an empty array without an initial value is an error.Syntax:array.reduceRight(function(total, currentValue, index, arr), initialValue) Parameters:Total(required): The previously returned value of the function. CurrentValue(Required): The value of the current element.M Index(Optional): The index of the current element. Arr(Optional): The array reduceRight() was called upon. InitialValue(Optional): A value to be passed to the function as the initial value. Return value:Return the reduced single value of the array. Browser Support:
ExampleJavaScript reduceRight() Method <script> // JavaScript to illustrate reduceRight() method // Taking some array as the element of an array "A" var A = [ ['Java','MongoDB' ], ['python','C'], [ 'RDBMS', 'C++' ] ]; // Calling array.reduceRight() function a = A.reduceRight((previousValue, currentValue) => previousValue.concat(currentValue)); // printing result document.write(a); // expected output: RDBMS,C++,python,C,Java,MongoDB </script> Output: RDBMS,C++, python, C, Java, MongoDB
Next TopicJavaScript TypedArray Object
|