shift
Remove an item from the front of a list.
list.shift()
shift
removes an element from the beginning of a DefineList.
import {DefineList} from "can";
const list = new DefineList(['Alice','Adam']);
console.log(list.shift()); //-> 'Alice'
console.log(list.shift()); //-> 'Adam'
console.log(list.shift()); //-> undefined
Returns
{*}
:
The element just shifted off the DefineList, or undefined
if the DefineList is empty
Use
shift
is the opposite action from unshift
:
Events
pop
causes remove and length events to be fired if the DefineList 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.