ArrayInsertAt
Append a value to an array
Method Signature
ArrayInsertAt(array=[modifiableArray], position=[integer], value=[any])
Arguments
Argument
Type
Required
Description
Default
array
modifiableArray
true
The array to be inserted into
position
integer
true
The position to insert at
value
any
true
The value to insert
Examples
Insert an Item in an Array at Position 2
Inserts the number 4 at position 2
someArray = [
1,
2,
3
];
arrayInsertAt( someArray, 2, 4 );
writeOutput( JSONSerialize( someArray ) );
Result: [1,4,2,3]
Additional Examples
fruitArray = [
"apple",
"kiwi",
"banana",
"orange",
"mango",
"kiwi"
];
arrayInsertAt( fruitArray, 3, "new inserted item" );
dump( fruitArray );
// member function
fruitArray.insertAt( 3, "member added item" );
dump( fruitArray );
Related
Last updated
Was this helpful?