Function removeProp

  • Removes a property from an object using a dot-notation path

    Type Parameters

    • T extends NestedObject
    • P extends string

    Parameters

    • obj: T

      The object to remove the property from

    • path: P

      The dot-notation path to the property (e.g., 'user.name')

    Returns T

    The modified object

    Throws

    Error if input validation fails

    Example

    const obj = { user: { name: 'Flavio Ever', age: 30 } };
    removeProp(obj, 'user.name'); // Removes the name property
    removeProp(obj, 'user.skills.0'); // Removes first element from array
    removeProp(obj, 'user.profile.social'); // Removes entire social object