Arrayobj. splice (START, deletecount, [Item1 [, item2 [,... [, itemn])
Parameters
Arrayobj
Required. An array object.
Start
Required. Specifies the start position of the element to be removed from the array. This position is calculated from 0.
Deletecount
Required. The number of elements to be removed.
Item1, item2,..., itemn
Required. The new element to be inserted at the position of the removed element.
Description
The splice method can remove the specified number of elements starting from the start position and insert new elements to modify arrayobj. The returned value is a new array object consisting of the removed elements.
Requirements
Release 5.5
CopyCode The Code is as follows: array. Prototype. Clear = function (){
This. Length = 0;
}
Array. Prototype. insertat = function (index, OBJ ){
This. splice (index, 0, OBJ );
}
Array. Prototype. removeat = function (INDEX ){
This. splice (index, 1 );
}
Array. Prototype. Remove = function (OBJ ){
VaR Index = This. indexof (OBJ );
If (index> = 0 ){
This. removeat (INDEX );
}
}
Usage:Copy codeThe Code is as follows: var A = [];
For (VAR I = 0; I <5; I ++) A. insertat (I, I );
Alert ();
A. removeat (1 );
Alert ();