JS Built-ins
← Proxy16 / 100
Proxyhasintermediate

Proxy has trap β€” always true

πŸ“– 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.

Proxy has trap

The has trap intercepts the in operator. When it always returns true, every key appears to exist.

Challenge: Verify that 'anything' in p is true when the has trap always returns true.

πŸ’‘ Hints (1)
  • β€’ The `has` trap intercepts the `in` operator: `key in proxy`.