Powered By GitBook
INSERT_ITEMS_AT
Insert items in list at the given index

Description

Return a copy of the list where a new items is inserted at the given index, pushing any following items to greater indexes.
If the index is negative, then the insertion position is counted from the end of the list

Function signature

1
INSERT_ITEMS_AT(array: Array, index: Number, newitems: Array) => Array
Copied!
Parameter
Description
Array
List
index
Index at which the items will be inserted
newItems
Items to insert

Examples

1
numbers = [1,2,3]
2
numbers2 = [999,1000]
3
objArr = [{"x":12,"y":23},{"x":24,"y":33},{"x":37,"y":48}]
4
newItems = [{"x":4,"y":20},{"x":-1,"y":12}]
Copied!
Formula
Return value
INSERT_ITEMS_AT(numbers, 1, numbers2)
[1,999,1000,2,3]
INSERT_ITEMS_AT(numbers, 10, numbers2)
[1,2,3,999,1000]
INSERT_ITEMS_AT(numbers, -1, numbers2)
[1,2,999,1000,3]
INSERT_ITEMS_AT(objArr, -10, newItems)
[{"x":4,"y":20},{"x":-1,"y":12},{"x":12,"y":23},{"x":24,"y":33},{"x":37,"y":48}]
Last modified 10mo ago
Export as PDF
Copy link