Parameter
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.
Any
ArrayReduceRight(array, function(result, item, [,index, array])[, initialValue])
ColdFusion (2021 release): Added this function.
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
|
initialValue |
Optional |
Initial value which will be used for the reduce operation. The type is any. |
<cfscript> data = ['1','2','3','4','5','6']; stringConcat = ArrayReduceRight(data,function(previous,next) { return previous & next; },""); writeOutput(stringConcat) </cfscript>
654321
<cfscript> data=[3,5,7,9,11] result=ArrayReduceRight(data,function(previous,next){ return previous & next },"") writeDump(result) </cfscript>
119753
<cfscript> data=[3,5,7,9,11] result=data.ReduceRight(function(previous,next){ return previous & next },"") writeDump(result) </cfscript>
119753
Sign in to your account