• function

shift can.Observe.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 [can.Observe.List.unshift unshift]:

var list = new can.Observe.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 [can.Observe.List.unshift unshift], or you may be looking for [can.Observe.List.push push] and its counterpart [can.Observe.List.pop pop].