---
title: "unique"
description: "Remove duplicate values from an array and return a new array of unique items, preserving the order of first appearance."
canonical_url: "https://core.mhaibaraai.cn/en/docs/utilities/array/unique"
---
# unique

> Remove duplicate values from an array and return a new array of unique items, preserving the order of first appearance.

## Usage

`unique` removes duplicate elements from an array.

```ts
import { unique } from '@movk/core'

const numbers = [1, 2, 2, 3, 3, 4]
const uniqueNumbers = unique(numbers)
console.log(uniqueNumbers) // [1, 2, 3, 4]

const strings = ['a', 'b', 'a', 'c']
const uniqueStrings = unique(strings)
console.log(uniqueStrings) // ['a', 'b', 'c']
```

## API

### `unique<T>(arr)`

Remove duplicate values from an array and return a new array of unique items.

### Parameters

**arr** (`T[]`) *required*: The array to deduplicate.

### Returns

**returns** (`T[]`): A new array with duplicates removed.

## Changelog

See commit history for [src/utilities/array/unique.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/utilities/array/unique.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/utilities/array/unique.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
