• function

push can.Observe.List.prototype.push

 

Add elements to the end of a list.

list.push(...elements)

push adds elements onto the end of a List.]

Parameters

  1. elements {*}

    the elements to add to the List

Returns

{Number}

the new length of the List

push is fairly straightforward:

var list = new can.Observe.List(['Alice']);

list.push('Bob', 'Eve');
list.attr(); // ['Alice', 'Bob', 'Eve']

If you have an array you want to concatenate to the end of the List, you can use apply:

var names = ['Bob', 'Eve'],
    list = new can.Observe.List(['Alice']);

list.push.apply(list, names);
list.attr(); // ['Alice', 'Bob', 'Eve']

Events

push causes change, add, and length events to be fired.

See also

push has a counterpart in [can.Observe.List.pop pop], or you may be looking for [can.Observe.List.unshift unshift] and its counterpart [can.Observe.List.shift shift].