Skip to content

JSArray.Insert

boxgaming edited this page Jul 25, 2026 · 3 revisions

Inserts items(s) into an array at a specified index location.

Syntax

JSArray.Insert a, index%, item1 [, item2, ... itemN]

Parameters

  • The a parameter contains the native JavaScript array on which the operation will be performed.
  • The index% parameter indicates the zero-based index at which to start changing the array.
  • 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.

Example

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

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

JSArray.Insert months, 1, "Feb"
Print JSArray.Join(months)

JSArray.Insert months, 4, "May", "Jun"
Print JSArray.Join(months)

Output

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

See Also

JSArray.Add
JSArray.Create
JSArray.Splice
JSArray.Join

Clone this wiki locally