📦 Archived documentation: r1 (committed 2026-07-24) View current documentation →

array.splice()

a.splice(start, deleteCount, [item1, item2, …])

Changes the contents of an array by removing existing elements and/or inserting new ones.

Arguments

NameTypeRequiredDefaultDescription
start number yes Index at which to start changing the array.
deleteCount number yes How many elements to remove from start.
items… any optional Elements to insert at start.

Example

let a = [1,2,3,4,5];
a.splice(1, 2, 100, 101, 102);
// a === [1,100,101,102,4,5]