unshift(...values)

Adds values to the beginning of a collection.

For purposes of genericity, collections that have an intrinsic relative order for their values, like a SortedSet, support the unshift method but do not necessarily add the new values to the beginning of the collection.

On collections

Usage

  • unshift(...values)

Examples

var list = new List([1, 2, 3]);
list.unshift(6, 4);
list.toArray();
var sortedSet = new SortedSet([2, 8, 5]);
sortedSet.toArray();
sortedSet.unshift(1, 6, 14);
sortedSet.toArray();

Related

  • pop()

    Removes a value from the end of a collection, and returns that value.

  • push(...values)

    Adds values to the end of a collection.

  • poke(value)

    Replaces the value at the beginning of a collection, the value that would be returned by shift().