arrayPop

Removes the last element from an array and returns the removed element. This will cause an exception on an empty array.

arrayPop(array) → returns any

Member Function Syntax

array.pop()

Argument Reference

array array
Required

The array whose last element is removed.

Compatibility

ColdFusion:

Version 2021+ The full function was added in ACF 2021, but the member function appears to work in ACF 2018 (likely using Java).

Lucee:

Version 5.3.8+ Lucee allows a second, optional argument defaultValue of any type that allows you to enter a default value to return if the array is empty.

Links more information about arrayPop

Examples
Sample code invoking the arrayPop function

This is the full function version of arrayPop to remove the last value of an array.

arr=[1,2,42];
p=arrayPop(array=arr);
writeOutput(p);

Expected Result: 42

Using the member function. This version also works in ACF2018.

arr=[1,2,42];
p=arr.pop();
writeOutput(p);

Expected Result: 42

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub