Array.removeAt Function
Removes an element from of an Array object at a specified index location. This function is static and can be invoked without creating an instance of the object.
Array.removeAt(array, index);
Arguments
Term |
Definition |
---|---|
array |
The array to remove the element from. |
index |
The index of the element to remove from the array. |
Remarks
Use the removeAt function to remove an item at a specific index from an array. The index value of items that are greater than index is decreased by one.
If index is a negative number, the removeAt function counts backward from the end of the array. Calling removeAt function with index greater than the length of the array has no effect.
Example
The following example shows how to invoke the removeAt function to remove an item at a specified index from an array.
var a = ['a', 'b', 'c', 'd', 'e'];
Array.remove(a, 'c');
// View the results: "a,b,d,e"
alert(a);
Array.removeAt(a, 2);
// View the results: "a,b,e"
alert(a);