isDefined function

Type guard for checking if a value is defined (not null or undefined).

Example

const items = [1, null, 3, undefined, 5];
const defined = items.filter(isDefined); // [1, 3, 5]

Signature

isDefined<T>(value: T): value is T

Parameters

value

Value to check

Returns

true if value is defined