24.16. Array.splice( ): insert, remove, or replace array elementsECMAScript v324.16.1. Synopsisarray.splice(start, deleteCount, value, ...) 24.16.1.1. Arguments
24.16.1.2. ReturnsAn array containing the elements, if any, deleted from array. 24.16.2. Descriptionsplice( ) deletes zero or more array elements starting with and including the element start and replaces them with zero or more values specified in the argument list. Array elements that appear after the insertion or deletion are moved as necessary so that they remain contiguous with the rest of the array. Note that, unlike the similarly named slice( ), splice( ) modifies array directly. 24.16.3. ExampleThe operation of splice( ) is most easily understood through an example: var a = [1,2,3,4,5,6,7,8] a.splice(4); // Returns [5,6,7,8]; a is [1,2,3,4] a.splice(1,2); // Returns [2,3]; a is [1,4] a.splice(1,1); // Returns [4]; a is [1] a.splice(1,0,2,3); // Returns []; a is [1 2 3] 24.16.4. See AlsoArray.slice( ) |