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.

Usage

public T[] splice(int startIndex)

Returns

An array of the removed elements.

Parameters

startIndex

The zero-based index of the array to begin removing elements from.

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.

Examples

Removing elements from specified starting index
1
2
3
4
5
import System;
 
int[] a = [ 1, 2, 3, 4, 5 ];
a.splice(3);
Console.log(a); // "1,2,3"
Removing elements and returning removed elements
1
2
3
4
import System;
 
int[] a = [ 1, 2, 3, 4, 5 ];
Console.log(a.splice(3)); // "4,5"

Share

HTML | BBCode | Direct Link