# 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`


---

# 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://docs.datajet-app.com/liquid/filters/pop.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.
