pop

Removes and returns the last element from an array. The original array is modified (mutated) and the removed element can be stored in a variable.

{% json items %}[1, 2, 3, 4, 5]{% endjson %}
{% pop items as last_item %}

{% log last_item %}
{% comment %} Output: 5 {% endcomment %}

{% log items %}
{% comment %} Output: [1, 2, 3, 4] {% endcomment %}

Syntax

{% pop array_name as variable_name %}

Parameters

Parameter
Required
Description

array_name

Yes

The array to remove the last element from

as variable_name

No

Variable to store the removed element

Behavior

  • Removes the last element from the array

  • Modifies the original array (mutation)

  • Returns null if the array is empty

  • Supports nested array access with dot notation

Examples

Basic pop operation:

Pop without storing the value:

Process array in reverse (LIFO):

Use with push for stack operations:

Pop from nested array:

Batch processing with pop:

Combine with conditionals:

Tag
Description

push

Adds an element to the end of an array

Notes

  • The array must exist and be a valid array, otherwise an error is thrown

  • Pop modifies the original array - use with caution if you need to preserve the original

  • Useful for implementing stack (LIFO - Last In, First Out) data structures

  • When the array is empty, the popped value will be null/undefined

  • Supports dot notation for nested arrays (e.g., data.items)

Last updated