unshift
Add items to the beginning of a DefineList.
list.unshift(...items)
unshift
adds items onto the beginning of a DefineList.
var list = new DefineList(['Alice']);
list.unshift('Bob', 'Eve');
list; // DefineList['Bob', 'Eve', 'Alice']
Parameters
- items
{*}
:The items to add to the DefineList.
Returns
{Number}
:
The new length of the DefineList.
Use
If you have an array you want to concatenate to the beginning
of the DefineList, you can use apply
:
var names = ['Bob', 'Eve'],
list = new DefineList(['Alice']);
list.unshift.apply(list, names);
list.get(); // ['Bob', 'Eve', 'Alice']
Events
unshift
causes add and length events to be fired.
See also
unshift
has a counterpart in shift, or you may be
looking for push and its counterpart pop.