Skip to main content

Pop Node

Pop Node Screenshot

Overview

The Pop Node is used to remove either the first or last element from an array and output both the removed element and the remaining array. By default, the Pop Node will pop the last element from the array.

This node is useful when you want to process elements of an array one by one in a loop.

Inputs

TitleData TypeDescriptionDefault ValueNotes
Arrayany[]The array to pop from(required)The input will be coerced into an array if it is not an array.

Example 1: Pop the last element from an array

  1. Create an Array Node and set the values to ["John", "Doe", "30", "Engineer"].
  2. Create a Pop Node and connect the Array Node to its Array input.
  3. Run the graph. The Last output of the Pop Node should be "Engineer" and the Rest output should be ["John", "Doe", "30"].

Pop Node Example 1

Example 2: Pop the first element from an array

  1. Create an Array Node and set the values to ["John", "Doe", "30", "Engineer"].
  2. Create a Pop Node, enable the Pop from front setting, and connect the Array Node to its Array input.
  3. Run the graph. The Last output of the Pop Node should be "John" and the Rest output should be ["Doe", "30", "Engineer"].

Pop Node Example 2

Error Handling

The Pop Node will error if the Array input is not provided, is not an array, or is an empty array.

FAQ

Q: Can I pop multiple elements from an array at once?

A: No, the Pop Node can only pop one element at a time. If you want to remove multiple elements from an array, you can use multiple Pop Nodes in a sequence.

Q: Can I use the Pop Node to pop elements from a string?

A: No, the Pop Node only works with arrays. If you want to remove characters from a string, you can use a Code Node with custom JavaScript code.

Q: What if the array is empty?

A: The Pop Node will error if the array is empty. You can use an If Node to check if the array is empty before popping from it.

See Also