Checks if a value is either null or undefined (i.e., "nullish"). This is a type guard that narrows the type to null | undefined.
null
undefined
null | undefined
For checking if a value is null, use isNull. For checking if a value is undefined, use isUndefined.
isNull
isUndefined
The value to check.
true if the value is null or undefined, false otherwise.
true
false
let myVar: string | null = null;if (isNullOrUndefined(myVar)) { // myVar is now typed as null | undefined} Copy
let myVar: string | null = null;if (isNullOrUndefined(myVar)) { // myVar is now typed as null | undefined}
1.0.0
Checks if a value is either
nullorundefined(i.e., "nullish"). This is a type guard that narrows the type tonull | undefined.For checking if a value is
null, useisNull. For checking if a value isundefined, useisUndefined.