> For the complete documentation index, see [llms.txt](https://docs.datajet-app.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datajet-app.com/liquid/filters/pop.md).

# pop

Removes and returns the last element from an array. Modifies the original array in place.

```liquid
{% assign last_item = my_array | pop %}
{% log last_item %}
```

#### Syntax

```liquid
{{ array | pop }}
```

| Parameter | Description                           |
| --------- | ------------------------------------- |
| `array`   | Array to remove the last element from |

#### Return Value

Returns the removed element. The original array is shortened by one element.

#### Examples

**Pop the last element:**

```liquid
{% assign colors = "red,green,blue" | split: "," %}
{% assign last = colors | pop %}
{% log last %}
{% log colors %}
```

Output:

```
blue
["red", "green"]
```

**Process items from the end:**

```liquid
{% assign stack = "first,second,third" | split: "," %}
{% assign item = stack | pop %}
{% log "Processing: " | append: item %}
{% log "Remaining: " | append: stack.size %}
```

**Use with the pop tag for named assignment:**

```liquid
{% pop my_array as last_element %}
{% log last_element %}
```

#### Notes

* Modifies the original array — the popped element is removed permanently
* Returns the input unchanged if it is not an array
* There is also a `{% pop array as variable %}` tag that does the same thing with a clearer syntax
* See also: `push`
