Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Farray%2Fisempty.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%2Fisempty.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `isEmpty`

## Description

Returns `true` if the array contains no elements, or `false` otherwise.

* Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `isEmpty` 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

```
isEmpty(array: array<T>): bool
```

```
(array: array<T>).isEmpty(): bool
```

## Arguments

| Name    | Type       | Required | Description                      |
| ------- | ---------- | -------- | -------------------------------- |
| `array` | `array<T>` | **true** | The array to check for emptiness |

## Example

**Use case: Check if an array is empty**

You can directly test whether an array has any elements:

```
create is_empty from isEmpty(my_array)
```

This produces a new boolean field indicating whether the array is empty.

**Use case 2: Optimize execution by skipping work when arrays are empty**

Suppose you have documents like the following:

```
{

    "names": ["Chip", "Ruby", "Glitch"]

},

{

    "names": []

}
```

If you want to join names into a string but avoid unnecessary computation for empty arrays, you can combine `isEmpty` with an `if` statement:

### Example query

* Function notation
* Method notation

```
create msg from if(!names.isEmpty(), names.arrayJoin(','), '')
```

```
create msg from if(!isEmpty(names), names.arrayJoin(','), '')
```

### Example output

For the above input, the results will look like:

```
{

    "names": ["Chip", "Ruby", "Glitch"],

    "msg": "Chip,Ruby,Glitch"

},

{

    "names": [],

    "msg": ""

}
```
