shift

  • function
can.List.prototype.shift  

Remove en element from the front of a list.

list.shift()

shift removes an element from the beginning of a List.

Returns

{*}

the element just shifted off the List, or undefined if the List is empty

shift is the opposite action from unshift:

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

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

list.shift(); // 'Bob'
list.shift(); // 'Eve'
list.shift(); // 'Alice'
list.shift(); // undefined

Events

pop causes change, remove, and length events to be fired if the List is not empty when it is called.

See also

shift has a counterpart in unshift, or you may be looking for push and its counterpart pop.