Overview

The Pop Block removes either the first or last element from an array and outputs both the removed element and the remaining array. By default, it pops the last element. This block is useful for processing array elements one by one in a loop.

Key Features

  • Removes and returns the first or last element of an array
  • Outputs both the popped element and the remaining array
  • Configurable to pop from the front or back of the array
  • Useful for iterative array processing

Inputs

array
any[]
required

The array to pop from. Required. Non-array inputs will not be coerced.

Outputs

lastItem
any

The popped element. Will be labeled as “First” if popping from front, “Last” if popping from back.

restOfArray
any[]

The remaining elements of the array after popping.

Editor Settings

fromFront
boolean
default:false

If enabled, the first element of the array will be popped instead of the last.

Example: Pop the last element from an array

  1. Create an Array Block with values ["John", "Doe", "30", "Engineer"].
  2. Add a Pop Block and connect the Array Block to its array input.
  3. Run the flow. The Last output should be "Engineer" and the Rest output should be ["John", "Doe", "30"].

Example: Pop the first element from an array

  1. Create an Array Block with values ["John", "Doe", "30", "Engineer"].
  2. Add a Pop Block, enable the Pop from front setting, and connect the Array Block to its array input.
  3. Run the flow. The First output should be "John" and the Rest output should be ["Doe", "30", "Engineer"].

Error Handling

The Pop Block will error if:

  • The array input is not provided
  • The input is not an array
  • The input array is empty

FAQ

See Also