Files
30-seconds-of-code/snippets/coalesce.md
Angelos Chalaris 3d79413392 Linting
2017-12-27 11:02:46 +02:00

11 lines
273 B
Markdown

### coalesce
Returns the first non-null/undefined argument.
Use `Array.find()` to return the first non `null`/`undefined` argument.
```js
const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));
// coalesce(null,undefined,"",NaN, "Waldo") -> ""
```