cfdocs

arrayLast

Returns the last item from an array. Throws an error if the array is empty.

arrayLast(array)
returns any

Member Function Syntax

array.last()

Argument Reference

Name Type Required Default Description
array array Yes    

Show the last element of an array

Uses the arrayLast function to retrieve the last element of an array

someArray = ["first", "second", "third"];
lastOne=arrayLast(someArray);
writeOutput(lastOne);

Expected Result: “third”