ts-data-forge
    Preparing search index...

    Function isNullish

    • Type guard that checks if a value is null or undefined (nullish).

      This function uses the loose equality operator (==) to check for both null and undefined in a single comparison, which is the standard JavaScript idiom for nullish checks.

      Type Narrowing Behavior:

      • Narrows the input type to null | undefined when true
      • Useful for checking if a value is "nullish" (either null or undefined)

      Parameters

      • u: unknown

        The value to check

      Returns u is null | undefined

      true if u is null or undefined, false otherwise. When true, TypeScript narrows the type to null | undefined.

      const values: (string | null | undefined)[] = ['Ada', null, undefined];

      const nullishValues = values.filter(isNullish);

      assert.deepStrictEqual(nullishValues, [null, undefined]);