Checks if a value is neither null nor undefined (i.e., "non-nullish"). This is a type guard that narrows the type away from null and undefined.
null
undefined
The type of the input value.
The value to check.
true if the value is not null and not undefined, false otherwise.
true
false
let myValue: string | null = "hello";if (isNonNullish(myValue)) { // myValue is now typed as string} Copy
let myValue: string | null = "hello";if (isNonNullish(myValue)) { // myValue is now typed as string}
1.0
isNullOrUndefined
Checks if a value is neither
nullnorundefined(i.e., "non-nullish"). This is a type guard that narrows the type away fromnullandundefined.