Skip to main content

array.insert(index, item)

Inserts an item into an array at the specified index


Device + Agent


Name Type Description
index Integer The index at which the value will be inserted
item Any Any Squirrel data type




This method places the value passed as its first parameter into the target array at the specified index, which can be zero — for the first item in the array — or greater. The item currently at that index, and all those that follow it, are automatically moved along one place to accommodate the new item.

If the index passed is greater than the number of objects in the array, Squirrel will present an ‘index out of range’ error.

The inserted value can be of any Squirrel data type. However, if functions and/or objects are inserted into the array, the array can no longer be serialized (see Squirrel Data Serialization).

Example Code