Function objIsEmpty

  • Checks if an object is empty. This function iterates over the keys of the provided object and checks if any key is defined.

    Type Parameters

    • T

    Parameters

    • obj: Record<string, T>

      The object to check.

    Returns boolean

    A boolean indicating whether the object is empty or not.

    Remarks

    This function uses the Object.keys() method to check if the object has any keys. If the object has at least one key, the function returns false, otherwise it returns true.

    Typeparam

    T - The type of the values in the object.

    Example

    const emptyObject = {};
    const nonEmptyObject = { key: 'value' };
    objIsEmpty(emptyObject);
    //=> true
    objIsEmpty(nonEmptyObject);
    //=> false

Generated using TypeDoc