arrayDeleteAt

Deletes the element at index from an array
The array will be resized, so that the deleted element doesn't leave a gap.

arrayDeleteAt(array, index) → returns boolean

Member Function Syntax

someArray.deleteAt(index)

arrayDeleteAt Argument Reference

array array
Required

The array that the element will be deleted from.

index numeric
Required

The numeric index of the element. Remember that ColdFusion arrays start at 1 not 0.

Examples sample code invoking the arrayDeleteAt function

Uses the arrayDeleteAt function to delete the value in specific position

someArray = ["Red", "White", "Green", "Blue", "Pink"];
arrayDeleteAt(someArray, 3);
writeOutput(serializeJSON(someArray));

Expected Result: ["Red", "White", "Blue", "Pink"]

CF 11+ Lucee 4.5+ Uses the member function is the same as running arrayDeleteAt.

someArray = ["Red", "White", "Green", "Blue", "Pink"];
someArray.DeleteAt(2);
writeOutput(serializeJSON(someArray));

Expected Result: ["Red", "Green", "Blue", "Pink"]


Fork me on GitHub