Function deleteProperty

  • Deletes the property resolved by a property path.

    By default, every path segment must be an own property. Set hasOwnOnly to false to permit inherited traversal; when the final property is inherited, the property is deleted from the prototype object that owns it. This explicit opt-in prevents accidental prototype mutation during ordinary use.

    Prototype-pollution keys (__proto__, prototype, and constructor) and ECMAScript well-known symbols are rejected at every path segment, matching the mutation hardening applied by safeSet. Non-configurable properties are not deleted.

    Parameters

    • data: object

      Object containing the property path.

    • path: PropertyPath

      Dotted or exact property-key path.

    • Optionaloptions: { hasOwnOnly?: boolean }

      Deletion options.

      • OptionalhasOwnOnly?: boolean

        Whether every path segment must be an own property; default: true.

    Returns boolean

    Whether an existing configurable property was deleted.

    If options.hasOwnOnly is not a boolean.