Whatever message this page gives is out now! Go check it out!

ArrayReduceRight

Last update:
May 18, 2026

Description

Iterates over every entry of the array and calls the closure to work on the elements of the array. This function will reduce the array to a single value from the right to the left and will return the value.

Returns

Any

Syntax

ArrayReduceRight(array, function(result, item, [,index, array])[, initialValue])

History

ColdFusion (2021 release): Added this function.

Parameters

Parameter
Required/Optional
Description
array
Required
The input array.
function
Required
Closure or a function reference that will be called for each of the iteration. The arguments passed to the callback are
  • result: result of the reduce operation after the previous iteration
  • item: item in the array
  • index : current index for the iteration
  • array : reference of the original array
initialValue
Optional
Initial value which will be used for the reduce operation. The type is any.

Example 1

<cfscript> 
       data = ['1','2','3','4','5','6']; 
       stringConcat = ArrayReduceRight(data,function(previous,next) { 
        return previous & next; 
       },""); 
       writeOutput(stringConcat) 
</cfscript>

Output

654321

Example 2

<cfscript> 
    data=[3,5,7,9,11] 
    result=ArrayReduceRight(data,function(previous,next){ 
        return previous & next 
    },"") 
    writeDump(result) 
</cfscript>

Output

119753

Example 3- member function

<cfscript> 
    data=[3,5,7,9,11] 
    result=data.ReduceRight(function(previous,next){ 
        return previous & next 
    },"") 
    writeDump(result) 
</cfscript>

Output

119753

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page