Skip to content

JSArray.Splice

boxgaming edited this page Jul 25, 2026 · 5 revisions

Changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.

Syntax

JSArray.Splice a, start% [, deleteCount%, item1, item2 ..., itemN]

Parameters

  • The a parameter contains the native JavaScript array on which the operation will be performed.
  • The start% parameter indicates the zero-based index at which to start changing the array.
  • The optional deleteCount% parameter indicates the number of elements in the array to remove from start. If not specified, all elements of the array will be removed.
  • Optionally, one or more item parameters can be passed to the method. Items will be inserted into the array in the order they appear in the list at the position indicated by start.

Example

Import JSArray From "lib/lang/array.bas"

Dim months As Object
months = JSArray.Create("Jan", "Mar", "Apr", "Jul", "Jun")

JSArray.Splice months, 1, 0, "Feb"
Print JSArray.Join(months)

JSArray.Splice months, 4, 1, "May"
Print JSArray.Join(months)

Output

Jan,Feb,Mar,Apr,Jul,Jun
Jan,Feb,Mar,Apr,May,Jun

See Also

JSArray.Create
JSArray.Join
JSArray.Slice
JSArray.Splice
JavaScript - Array.splice()

Clone this wiki locally