JS Built-ins
Proxygetbeginner

Proxy get trap β€” passthrough (no trap)

πŸ“– Usage Example
const p = new Proxy({}, {
  get: (target, key) => 'got ' + String(key)
})
console.log(p.foo) // β†’ 'got foo'
console.log(p.bar) // β†’ 'got bar'

The get trap intercepts property reads on a proxy, letting you return custom values for any key instead of actual target values.

Proxy without get trap

An empty handler means the proxy forwards all reads to the target unchanged.

Challenge: Verify that new Proxy({x: 10}, {}).x === 10.

πŸ’‘ Hints (1)
  • β€’ Without a `get` trap, the proxy reads directly from the target.