ArrayUnshift
This function adds one or more elements to the beginning of the original array and returns the length of the modified array.
Method Signature
ArrayUnshift(array=[modifiablearray], object=[any])Arguments
Argument
Type
Required
Description
Default
array
modifiablearray
true
The array to add an item to
object
any
true
The value to add
Examples
Example with simple values
Add a new element to an array.
arr = [
1,
2,
3
];
newArrLen = arrayUnshift( arr, 0 );
writeOutput( newArrLen );
Result: 4
Using a member function
This is the same example as above, but using a member function on the array instead of a standalone function.
Result: 4
Additional Examples
Related
Last updated
Was this helpful?
