# || (arrays and objects)

[Read this page in HTML](https://www.scopedb.io/docs/reference/functions/semi-structured-data/concat)

Concatenates arrays or merges objects with the `||` operator.

## Syntax

```scopeql
<left> || <right> [|| <next> ...]
```

## Arguments

| Argument  | Type                | Description                         |
| --------- | ------------------- | ----------------------------------- |
| `<left>`  | `array` or `object` | First value.                        |
| `<right>` | Same as `<left>`    | Array to append or object to merge. |
| `<next>`  | Same as `<left>`    | Optional additional values.         |

## Returns

Returns the same type as the inputs.

* Arrays preserve element order, duplicates, and NULL elements.
* Objects combine their top-level keys. For duplicate keys, the right-hand value replaces the left-hand value, including nested objects.
* If any input is NULL, returns NULL.

## Examples

### Combine event labels

Combine labels from an event and an investigation. Concatenation preserves both order and duplicates.

```scopeql
SELECT ['checkout', 'timeout'] || ['timeout', 'reviewed'] AS labels
```

The `labels` value:

```text
[
  "checkout",
  "timeout",
  "timeout",
  "reviewed"
]
```

Use `dedup` on the combined array when the result should contain each label only once.

### Apply event-specific attributes

Merge shared context with event-specific attributes. The right-hand object overrides a shared key.

```scopeql
SELECT
    {'region': 'apac', 'channel': 'web'} ||
    {'channel': 'mobile', 'campaign': 'spring'} AS attributes
```

The `attributes` value:

```text
{
  "campaign": "spring",
  "channel": "mobile",
  "region": "apac"
}
```

The resulting `channel` is `mobile`; `region` is retained from the left-hand object.
