pop
Remove an element from the end of a DefineList.
list.pop()
pop
removes an element from the end of a DefineList.
import { DefineList } from "can";
const names = new DefineList(['Alice', 'Bob', 'Eve']);
console.log(names.pop()); //-> 'Eve'
Returns
{*}
:
The element just popped off the DefineList, or undefined
if the DefineList was empty
Use
pop
is the opposite action from push:
import {DefineList} from "can";
const list = new DefineList(['Alice', 'Bob', 'Eve']);
console.log(list.pop()); //-> 'Eve'
console.log(list.pop()); //-> 'Bob'
console.log(list.pop()); //-> 'Alice'
console.log(list.pop()); //-> undefined
Events
pop
causes remove and length events to be fired if the DefineList is not empty
when it is called.
See also
pop
has its counterpart in push, or you may be
looking for unshift and its counterpart shift.