Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Farray%2Farrayappend.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Farray%2Farrayappend.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `arrayAppend`

## Description

Returns a new array with an additional element appended to the end of an existing array.

* The element type must match the array type.
* Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `arrayAppend` supports<!-- --> [two notations](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
arrayAppend(array: array<T>, element: T): array<T>
```

```
(array: array<T>).arrayAppend(element: T): array<T>
```

## Arguments

| Name      | Type       | Required | Description                                      |
| --------- | ---------- | -------- | ------------------------------------------------ |
| `array`   | `array<T>` | **true** | The base array to modify                         |
| `element` | `T`        | **true** | The element to append, must match the array type |

## Example

**Use case: Add a missing value to an array for consistency in processing**

Suppose you have an array of job names but need to include an additional value from another field. Consider the following input:

```
{

    "my_values": ["Job 1", "Job 2", "Job 3"],

    "my_other_value": "Job 4"

}
```

By appending `my_other_value` to `my_values`, you can ensure all values are included in the array for downstream processing.

### Example query

* Function notation
* Method notation

```
replace my_values with arrayAppend(my_values, my_other_value)
```

```
replace my_values with my_values.arrayAppend(my_other_value)
```

### Example output

The result will include the new element at the end of the array:

```
{

    "my_values": ["Job 1", "Job 2", "Job 3", "Job 4"],

    "my_other_value": "Job 4"

}
```
