pull()
: The pull() method removes and returns an item from the collection by its key:
const collection = collect({
firstname: 'Michael',
lastname: 'Cera',
});
collection.pull('lastname');
// Cera
collection.all();
// { firstname: 'Michael' }
push()
: The push() method appends an item to the end of the collection:
const collection = collect([1, 2, 3, 4]);
collection.push(5);
collection.all();
// [1, 2, 3, 4, 5]
put()
: The put() method sets the given key and value in the collection:
const collection = collect(['JavaScript', 'Python']);
collection.put('Ruby');
collection.all();
// ['JavaScript', 'Python', 'Ruby']