Array Power, Part II - DHTML Lab | 5 | WebReference

Array Power, Part II - DHTML Lab | 5


Array Power, Part II
push() demo

In the following example, we start with an empty array.

The SELECT menu has several values which you can add as elements to the array. They are a mix of string, Boolean, number and array values. Select one or more value to add it to the array.

The statement generated to add the new element(s) is displayed in the Statement field.

The contents of the array before the push() method is used appears in the Old myArray field.

The current contents of the array, after push(), are displayed in the New myArray field.

The statement's return value appears in the arLength field.

Old myArray: (before push())
New myArray: (after push())
Statement generated:
1. Select one or more of these options to add to array: 2. Click to add to array:

The push() method, of course, is complemented by the pop() method.

Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: May 2, 2000
Revised: May 2, 2000