ts-data-forge
    Preparing search index...

    Function isNull

    • Type guard that checks if a value is null.

      Type Narrowing Behavior:

      • Narrows the input type to null when true
      • Useful for explicit null checks

      Parameters

      • u: unknown

        The value to check

      Returns u is null

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

      const values: readonly (number | null)[] = [null, 5] as const;

      const nullValues = values.filter(isNull);

      assert.deepStrictEqual(nullValues, [null]);