Function nullish

  • Check if something is null or undefined.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • value: unknown

      Value to check

    Returns value is Nullish

    true if value is nullish, false if otherwise

    Example

    const value = Math.random() > 0.5 ? 'hello' : null;

    nullish(value);