Array splice()
syntax: |
array.splice(start, deleteCount[, element1, ...]) |
where: |
start - the index at which to splice in the items. If this is negative, then (length+start) is used instead, and if it beyond the end of the array, then the length of the array is used.
deletecount - the number of items to remove from the array.
elementN - a list of elements to insert into the array in place of the ones which were deleted.
|
return: |
object - an array consisting of the elements which were removed from the current Array object.
|
description: |
This method splices in any supplied elements in place of any elements deleted. Beginning at index start, deleteCount elements are first deleted from the array and inserted into the newly created return array in the same order. The elements of the current object are then adjusted to make room for the all of the items passed to this method. The remaining arguments are then inserted sequentially in the space created in the current object.
|
see: |
|
example: |
// The following code:
var array = new Array( 1, 2, 3, 4, 5 ); Screen.writeln( array.splice( 1, 2, 6, 7, 8 ); Screen.writeln( array );
// Will print "2,3" and then "1,6,7,8,4,5".// // The array has been modified to include // the extra items in place of those // that were deleted. |