JS Built-ins
Proxygetintermediate

Proxy get trap β€” append ! to key

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

The get trap intercepts property reads. Use it to transform the key.

Challenge: Verify that a proxy with get: (t, k) => k + '!' returns 'foo!' for p.foo.

πŸ’‘ Hints (1)
  • β€’ The `get` trap receives `(target, key, receiver)` β€” use `key` to build the return value.