JS Built-ins
← Proxy20 / 100
Proxyhasintermediate

Proxy has trap β€” y is absent

πŸ“– Usage Example
const p = new Proxy({}, {
  has: (target, key) => key.startsWith('a')
})
console.log('apple' in p)  // β†’ true
console.log('banana' in p) // β†’ false

The has trap intercepts the in operator, allowing you to control which property names are considered present on a proxy.

has trap β€” y not visible

When the has trap only returns true for 'x', the key 'y' is not visible via in.

Challenge: Verify that 'y' in p is false when has returns key === 'x'.

πŸ’‘ Hints (1)
  • β€’ When the condition is false, `has` returns `false` for that key.