The value to check.
true
if the check passes, false
otherwise.
isNullish(null) // true
isNullish(undefined) // true
isNullish(0) // false
const value: string | null | undefined
if (isNullish(value)) {
value // type: null | undefined
} else {
value // type: string
}
// or
if (!isNullish(value)) {
value // type: string
} else {
value // type: null | undefined
}
import { assert } from 'uft'
const token: string | null | undefined
assert(!isNullish(token), 'received nullish token')
token // string
Generated using TypeDoc
Checks if a value is
null
orundefined
.