ArrayPrepend()

Inserts an array element at the beginning of an array and shifts the positions of the existing elements to make room.

ArrayPrepend( array=array, value=any, merge=boolean );

Returns: Boolean

Argument Description
array
array, required

Name of an array

value
any, required

value to prepend

merge
boolean, optional

This argument only applies when the value is an array. If set to true prepend array elements individually to the source array. If false (default) the complete array is added as one element at the top, in the source array.

Examples

Add an array item on to the front of an array

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

// member function doctorWhoArray = ['Whittaker','Tennant','Baker']; doctorWhoArray.prepend('Hurt'); dump(doctorWhoArray);

See also