451 B
451 B
title, tags, firstSeen, lastUpdated
| title | tags | firstSeen | lastUpdated |
|---|---|---|---|
| coalesce | type,beginner | 2017-12-17T10:08:55+02:00 | 2020-09-15T16:28:04+03:00 |
Returns the first defined, non-null argument.
- Use
Array.prototype.find()andArray.prototype.includes()to find the first value that is not equal toundefinedornull.
const coalesce = (...args) => args.find(v => ![undefined, null].includes(v));
coalesce(null, undefined, '', NaN, 'Waldo'); // ''