JS Built-ins
← Proxy24 / 100
ProxydeletePropertybeginner

Proxy deleteProperty trap β€” key removed from target

πŸ“– 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 β€” passthrough removes key

After a passthrough delete, the property no longer exists on the proxy (or its target).

Challenge: Verify that after delete p.x, 'x' in p is false.

πŸ’‘ Hints (1)
  • β€’ A passthrough `delete` removes the key from the target, so `in` returns `false`.