Array Power, Part III - DHTML Lab | 3 | WebReference

Array Power, Part III - DHTML Lab | 3

Logo

Array Power, Part III
splice() demo


In the following example, we start with our usual array: [0,"cat",true]

Enter a first argument for splice() in the Index field.

Enter a second argument for splice() in the Count field.

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 values to add to the array.

Click the splice( ) button to execute the splice() method.

The JavaScript statement generated is displayed in the Statement field.

The contents of the array before the statement is executed are displayed in the Old myArray field.

The contents of the array after the statement is executed are displayed in the New myArray field.

The splice() method's return value appears in the removedElements field.

Original myArray: [0,"cat",true]
Old myArray:
New myArray:
removedElements:
Statement:
1. Enter a first argument (pointer index):
Index:

2. Enter a second argument (element count):
Count:
3. Select one or more of these options to add as elements to the array:


   

Now on to a simple real world use for splice().


Produced by Peter Belesis and

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

URL: http://www.webreference.com/dhtml/column33/11.html