tguard-js
    Preparing search index...

    Function isNullOrUndefined

    • Checks if a value is either null or undefined (i.e., "nullish"). This is a type guard that narrows the type to null | undefined.

      For checking if a value is null, use isNull. For checking if a value is undefined, use isUndefined.

      Parameters

      • x: unknown

        The value to check.

      Returns x is null | undefined

      true if the value is null or undefined, false otherwise.

      let myVar: string | null = null;
      if (isNullOrUndefined(myVar)) {
      // myVar is now typed as null | undefined
      }

      1.0.0