Skip to content

arrayRemoveAt - Removes element from array at given position

arrayRemoveAt will return an array with the element at the given position removed.

Syntax

Like many functions in DataPrime, arrayRemoveAt supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

arrayRemoveAt(array: array<T>, position: number): array<T>
array: array<T>.arrayRemoveAt(position: number): array<T>

Arguments

NameTypeRequiredDescription
arrayarray of type TtrueT must be either string, bool, number, interval, timestamp, regexp or enum
positionnumbertrueThe position at which to remove the element from the array. This value is 0 indexed

Example - Removing a job from the middle of a queue

Consider the following document:

{
    "values": ["Job 1", "Job 2", "Job 3", "Job 4"]
}

Removing an item from a given point in an array is as simple as:

replace values with arrayRemoveAt(values, 2)
replace values with values.arrayRemoveAt(2)

This results in the following document:

{
    "values": ["Job 1", "Job 2", "Job 4"]
}

Try it yourself

Open up your explore screen and enter the following command:

create values from ['Job 1', 'Job 2', 'Job 3', 'Job 4']
| create updated_values from values.arrayRemoveAt(2)