PK

ADDRLIN : /home/questend/public_html/domains/flaxzy.com/node_modules/collect.js/docs/api/
FLL :
Current File : /home/questend/public_html/domains/flaxzy.com/node_modules/collect.js/docs/api/whenEmpty.md

# `whenEmpty()`

The `whenEmpty` method will execute the given callback when the collection is empty:

```js
const collection = collect([]);

collection.whenEmpty(c => c.push('Mohamed Salah'));

collection.all();

// ['Mohamed Salah']
```

```js
const collection = collect(['Sadio Mané']);

collection.whenEmpty(
  c => c.push('Mohamed Salah'),
  c => c.push('Xherdan Shaqiri'),
);

collection.all();

// [
//   'Sadio Mané',
//   'Xherdan Shaqiri',
// ];
```

[View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/whenEmpty.js)


PK 99
E-SHOP || DASHBOARD
404

Page Not Found

It looks like you found a glitch in the matrix...

← Back to Home