Array Power, Part I - DHTML Lab | 8 | WebReference

Array Power, Part I - DHTML Lab | 8


Array Power, Part I
shift() demo

In this example, we start with an array composed of elements of various types.

Click the shift( ) button, to remove an element from the array.

The statement generated is displayed in the Statement field.

The current contents of the array are displayed in the New myArray field. The statement's return value appears in the numeroUno field.

The Type field is for reference only, demonstrating that the type of object returned from the method is respected.

Original myArray: [0,1,2,true,3,"cat",4,[0,1,2,false,3,"dog",4,5],5]
New myArray:
numeroUno: Type:
Statement: numeroUno = myArray.shift()

"But what use are these methods in the real-world?", you ask! Hmmm. Glad you asked that question.

Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: April 26, 2000
Revised: April 26, 2000