JS Built-ins
ProxyProxybeginner

Proxy() β€” instanceof Object

πŸ“– Usage Example
const target = { value: 42 }
const p = new Proxy(target, {
  get: (t, k) => k in t ? t[k] : 'default'
})
console.log(p.value)   // β†’ 42
console.log(p.missing) // β†’ 'default'

new Proxy(target, handler) creates a proxy that intercepts operations on the target object using trap methods in the handler.

Proxy constructor

A Proxy wraps an object and intercepts operations. A proxy of an object is still an Object instance.

Challenge: Verify that new Proxy({}, {}) instanceof Object is true.

πŸ’‘ Hints (1)
  • β€’ A `Proxy` forwards operations to the target, so it inherits the target's prototype chain.