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

array array
Required

Examples
Sample code invoking the arrayLast function

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

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

Expected Result: "third"

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub