The value to check.
// Basic usage
isNullish(null); // => true
isNullish(undefined); // => true
isNullish(0); // => false
isNullish(''); // => false
// Using as a type guard to filter out nullish values
const values = [1, undefined, 2, null, 3];
const nonNullishValues = values.filter(v => !isNullish(v));
// nonNullishValues is now [1, 2, 3]
// and its type has been narrowed to number[]
Checks if the provided value is null or undefined. This is equivalent to
x == nullbut is more explicit and provides a type guard.