splice Summary Removes elements from the specified starting array index to the end of the array. Signatures Click on a signature to select it and view its documentation. public T[] splice(int startIndex) public T[] splice(int startIndex, int deleteCount) public T[] splice(int startIndex, int deleteCount, ...T replaceElements) Usage public T[] splice(int startIndex) public T[] splice(int startIndex, int deleteCount) public T[] splice(int startIndex, int deleteCount, ...T replaceElements) Returns An array of the removed elements. An array of the removed elements. An array of the removed elements. Parameters startIndex The zero-based index of the array to begin removing elements from. Parameters startIndex The zero-based index of the array to begin removing elements from. deleteCount The number of elements to remove. Parameters startIndex The zero-based index of the array to begin removing elements from. deleteCount The number of elements to remove. replaceElements The elements to replace the deleted elements with. Description Removes elements from the specified starting array index to the end of the array. Returns an array of the removed elements. This method mutates the array. Removes elements from the specified starting array index for the specified deletion count. Returns an array of the removed elements. This method mutates the array. Removes elements from the specified starting array index for the specified deletion count and replaces the deleted elements with the specified replacement elements. Returns an array of the removed elements. This method mutates the array. Examples Removing elements from specified starting index 12345import System; int[] a = [ 1, 2, 3, 4, 5 ];a.splice(3);Console.log(a); // "1,2,3" Removing elements and returning removed elements 1234import System; int[] a = [ 1, 2, 3, 4, 5 ];Console.log(a.splice(3)); // "4,5" Removing the first two elements 12345import System; int[] a = [ 1, 2, 3, 4, 5 ];a.splice(0, 2);Console.log(a); // "3,4,5" Replacing the first two elements 12345import System; int[] a = [ 1, 2, 3, 4, 5 ];a.splice(0, 2, 0, 1);Console.log(a); // "0,1,3,4,5" Share HTML | BBCode | Direct Link