This function iterates over every element of the string and calls the closure to work on that element. This function will reduce the string to a single value, from the right to the left, and will return the value.
NOTE: This function is not available in Lucee 5.x or lower. Potentially use reverse()
instead.
stringReduceRight(string, callback, initialValue)
→ returns any
string.reduceRight(callback, initialValue)
result
*
any
:
The result of the reduce operation after the previous iteration.
item
*
any
:
The value for the current iteration's item.
index
*
numeric
:
The current index for the iteration
array
*
array
:
A reference of the original array
This function will be added to Lucee in Version 6. But if you need to reverse a string now, use the reverse()
function.
myString="abcd";
newString=myString.reverse();
writedump(newString);
Expected Result: dcba
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.