jty
    Preparing search index...

    Function isNullish

    • Checks if the provided value is null or undefined. This is equivalent to x == null but is more explicit and provides a type guard.

      Parameters

      • x: unknown

        The value to check.

      Returns x is null | undefined

      // Basic usage
      isNullish(null); // => true
      isNullish(undefined); // => true
      isNullish(0); // => false
      isNullish(''); // => false

      // Using as a type guard to filter out nullish values
      const values = [1, undefined, 2, null, 3];
      const nonNullishValues = values.filter(v => !isNullish(v));
      // nonNullishValues is now [1, 2, 3]
      // and its type has been narrowed to number[]

      isDef