ArrayPrepend

Append a value to the start an array

Method Signature

ArrayPrepend(array=[modifiableArray], value=[any])

Arguments

Argument
Type
Required
Description
Default

array

modifiableArray

true

The array to prepend to

value

any

true

The value to prepend

Examples

Prepend a value to an array

Uses the arrayPrepend function to prepend a value to the beginning of an array and shifts the positions of the existing elements.

Run Example

someArray = [ 
	3,
	2,
	1
];
arrayPrepend( someArray, 4 );
writeDump( someArray );

Result: [4,3,2,1]

Prepend a value to an array using the Array member function

Invoking the prepend function on an array is the same as running arrayPrepend.

Run Example

Result: ['Hurt','Eccleston','Tennant','Smith','Capaldi']

Additional Examples

Run Example

Last updated

Was this helpful?