# whenEmpty()
The whenEmpty
method will execute the given callback when the collection is empty:
const collection = collect([]);
collection.whenEmpty(c => c.push('Mohamed Salah'));
collection.all();
// ['Mohamed Salah']
const collection = collect(['Darwin Núñez']);
collection.whenEmpty(
c => c.push('Mohamed Salah'),
c => c.push('Xherdan Shaqiri'),
);
collection.all();
// [
// 'Darwin Núñez',
// 'Xherdan Shaqiri',
// ];
← when() whenNotEmpty() →