array.pop()

pops the last element from an array. In case the array is empty an exception is thrown, unless the second argument "defaultValue" is provided, in that case that value is returned.

array.pop( defaultValue=any )

Returns: any

Argument Description
defaultValue
any, optional

this value is returned in case the array is empty

Examples

Arraypop member examples

numbers = [ 1, 2, 3, 4 ];
	Dump( numbers.pop( 0 ) ); // Outputs 4
	moreNumbers = [ 5, 6, 7, 8 ];
	Dump( moreNumbers.pop( 4 ) ); // Outputs 8
	moreNumbers = [  ];
	Dump( moreNumbers.pop( 4 ) ); // Outputs 4

See also