JS Built-ins
Proxygetintermediate

Proxy get trap β€” double value

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

get trap β€” transform target values

The get trap can access the real target and transform its values.

Challenge: Verify that a proxy doubling target[key] returns 2 for a target {a: 1}.

πŸ’‘ Hints (1)
  • β€’ Access `target[key]` inside the trap to get the original value.