---
name: "pushBackUnique"
type: command
status: ok
groups: ["Arrays"]
arma3_since: "1.56"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/pushBackUnique
revid: 377140
updated: 2026-01-01T10:30:41Z
---

# pushBackUnique

*Command · Arrays · Arma 3 v1.56*

## Description

Adds element to the back of the given array but only if it is unique to the array. The index of the added element is returned upon success, otherwise -1. This command modifies the original array.

> [!NOTE]
> Adding string elements is **case sensitive**.

## Syntax

```sqf
array pushBackUnique element
```

**Parameters:**

- `array`: [Array](../topics/Array.md) of [Anything](../topics/Anything.md)
- `element`: [Anything](../topics/Anything.md)

**Returns:** [Number](../topics/Number.md) - index of inserted element or -1

## Examples

### Example 1

```sqf
_arr = [1,2,3];
_index = _arr pushBackUnique 3;
hint str [_index, _arr]; // [-1,[1,2,3]]
```

### Example 2

```sqf
_arr = [1,2,3];
_index = _arr pushBackUnique 4;
hint str [_index, _arr]; // [3,[1,2,3,4]]
```

## See also

[pushBack](../commands/pushBack.md) · [select](../commands/select.md) · [set](../commands/set.md) · [resize](../commands/resize.md) · [reverse](../commands/reverse.md) · [count](../commands/count.md) · [find](../commands/find.md) · [in](../commands/in.md) · [forEach](../commands/forEach.md) · [deleteAt](../commands/deleteAt.md) · [deleteRange](../commands/deleteRange.md) · [append](../commands/append.md) · [sort](../commands/sort.md) · [arrayIntersect](../commands/arrayIntersect.md) · [apply](../commands/apply.md) · [BIS_fnc_arrayPushStack](../functions/BIS_fnc_arrayPushStack.md) · [BIS_fnc_arrayPush](../functions/BIS_fnc_arrayPush.md)

<sub>Source: [BI Community Wiki — pushBackUnique](https://community.bistudio.com/wiki/pushBackUnique) (revision 377140).</sub>
