arrayReverse

Returns an array with all of the elements reversed. The value in [0] within the input array will then exist in [n] in the output array, where n is the amount of elements in the array minus one.

arrayReverse(array) → returns array

Member Function Syntax

array.reverse()

This function requires Lucee. Not supported on Adobe ColdFusion.

arrayReverse Argument Reference

array array
Required

The array to reverse

Examples sample code invoking the arrayReverse function

Creates a new array with reversed positions

myArray = [1,2,3];
myArrayReversed = arrayReverse(myArray);
writeOutput( serializeJSON( myArrayReversed ) );

Expected Result: [3,2,1]

myArray = [1,2,3]; 
writeOutput( serializeJSON( myArray.reverse() ) );

Expected Result: [3,2,1]


Fork me on GitHub