arrayIndexExists

Returns whether there exists an item in the array at the selected index.

arrayIndexExists(array, index) → returns boolean

Member Function Syntax

array.indexExists(index)

This function requires Lucee.  Not supported on Adobe ColdFusion, etc.

Argument Reference

array array
Required

index numeric
Required

Examples
Sample code invoking the arrayIndexExists function

In this example, the index we are checking exists in the array so the check returns true.

myArray=[];
myArray[1]='one';
myArray[2]='two';
myArray[3]='three';
myArray[4]='four';
myArray[5]='five';
result = arrayIndexExists(myArray, 3);
writeOutput(result);

Expected Result: true

In this example, there is no element at the index we're checking so the check returns false.

myArray=[];
myArray[1]='one';
myArray[2]='two';
// no element at index 3
myArray[4]='four';
myArray[5]='five';
result = arrayIndexExists(myArray, 3);
writeOutput(result);

Expected Result: false

In this example, the array we are searching is empty so the check returns false.

myArray=[];
result = arrayIndexExists(myArray, 3);
writeOutput(result);

Expected Result: false

In this example, the index we are checking exists in the array so the check returns true.

myArray=[];
myArray[1]='one';
myArray[2]='two';
myArray[3]='three';
myArray[4]='four';
myArray[5]='five';
result = myArray.indexExists(3);
writeOutput(result);

Expected Result: true

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

Fork me on GitHub