# unique

Removes duplicate values from an array, returning a new array with only unique elements. Order is preserved — the first occurrence of each value is kept.

#### Syntax

```
unique(array)
```

or chained:

```
<array>.unique()
```

#### Arguments

* **array** (`array`, optional when chained) - The array to deduplicate.

#### Examples

**Deduplicate numbers**

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

**Deduplicate strings**

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

**CLI usage — get unique tags**

```bash
$ echo '{"tags": ["go", "cli", "go", "json", "cli"]}' | dasel -i json 'tags.unique()'
[
    "go",
    "cli",
    "json"
]
```

**Chained with other functions**

```
[3, 1, 2, 1, 3].unique().sortBy()
// [1, 2, 3]
```


---

# 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/unique.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.
