arrayDeleteAt

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

arrayDeleteAt(array, position) → returns boolean

Member Function Syntax

someArray.deleteAt(position)

Argument Reference for the arrayDeleteAt function

array

Required: Yes
The array that the element will be deleted from.

position

Required: Yes
The numeric position of the element. Remember that ColdFusion arrays start at 1 not 0.

Examples sample code invoking the arrayDeleteAt function


Simple example for 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"]


Simple example with member function

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