JS Built-ins
← Proxy22 / 100
ProxydeletePropertybeginner

Proxy deleteProperty trap β€” passthrough

πŸ“– Usage Example
const log = []
const p = new Proxy({}, {
  deleteProperty: (t, k) => { log.push(k); return true }
})
delete p.foo
console.log(log) // β†’ ['foo']

The deleteProperty trap intercepts delete operations, allowing custom logic when a property is deleted from a proxy.

deleteProperty β€” no trap

Without a deleteProperty trap, delete forwards to the target and actually removes the property.

Challenge: Verify that after delete p.x, p.x is undefined.

πŸ’‘ Hints (1)
  • β€’ Without a trap, `delete proxy.key` delegates to the target object.