ArrayPrepend

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

ArrayPrepend( array, value [, merge ] )

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
doctorArray.prepend('Hurt');
dump(doctorArray);

See also