contents   index   previous   next



Array pop()

syntax:

array.pop()

return:

value - the last element of the current Array object. The element is removed from the array after being returned.

 

description:

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

 

see:

Array push()

 

example:

// The following code:

 

var array = new Array( "four" );

Screen.writeln( array.pop() );

Screen.writeln( array.pop() );

 

// Will first print out the string "four", and

// then print out "undefined",

// which is the result of converting

// the undefined value to a string.

// The array will be empty after these calls.

 


Array push()