arrayFirst

Returns the first item from an array.

arrayFirst(array) → returns any

Member Function Syntax

array.first()

Argument Reference

array array
Required

Examples
Sample code invoking the arrayFirst function

Use the member function to return the first item from an array

someArray = [1,2,3,4];
WriteOutput(someArray.first());

Expected Result: 1

Return the first item from an array

seinfeldArray = ["Jerry","Elaine","Kramer","George"];
WriteOutput(arrayFirst(seinfeldArray));

Expected Result: "Jerry"

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

Fork me on GitHub