Siebel eScript Language Reference > Siebel eScript Commands > Array Objects >

Array pop() Method


This method returns the last element of the current Array object, then removes the element from the array.

Syntax

arrayName.pop()

Returns

The last element of the current Array object.

Usage

This method first gets the length of the current Array object. If the length is undefined or 0, then undefined is returned. Otherwise, the last element is returned. This element is then deleted, and the length of current array object is decreased by one. The pop() method works on the end of an array, whereas, the Array shift() method works on the beginning.

Example

var a = new Array( "four" );
TheApplication().RaiseErrorText("First pop: " + a.pop() + ", Second pop: " + a.pop());
// First displays the last (and only) element, the string "four".
// Then displays "undefined" because the array is empty after
// the first call removes the only element.

Siebel eScript Language Reference