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