JS Built-ins
ProxyProxybeginner

Proxy() β€” typeof

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

typeof a Proxy

typeof new Proxy({}, {}) returns 'object' because the proxy wraps a plain object.

Challenge: Verify that typeof new Proxy({}, {}) returns 'object'.

πŸ’‘ Hints (1)
  • β€’ `typeof` on a proxy of an object returns `'object'`.