# first

Returns the first element of an array. Returns `null` if the array is empty.

#### Syntax

```
first(array)
```

or chained:

```
<array>.first()
```

#### Arguments

* **array** (`array`, optional when chained) - The array to get the first element from.

#### Examples

**Get the first number**

```
first([1, 2, 3])
// 1
```

**Chained usage**

```
["a", "b", "c"].first()
// "a"
```

**Empty array returns null**

```
first([])
// null
```

**CLI usage — get the first user**

```bash
$ echo '{"users": ["Alice", "Bob", "Charlie"]}' | dasel -i json 'users.first()'
Alice
```

**Chained with filter**

```
[1, 2, 3, 4, 5].filter($this > 3).first()
// 4
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://daseldocs.tomwright.me/functions/first.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
