JS Built-ins
← Proxy15 / 100
Proxysetbeginner

Proxy β€” constructor typeof

πŸ“– Usage Example
const log = []
const p = new Proxy({}, {
  set: (t, k, v) => { log.push(String(k) + '=' + v); t[k] = v; return true }
})
p.x = 10
console.log(log) // β†’ ["x=10"]

The set trap intercepts property assignments on a proxy, letting you validate or observe writes before they reach the target.

typeof proxy.constructor

A proxy of a plain object forwards the constructor property lookup to the target, which points to Object. typeof that is 'function'.

Challenge: Verify that typeof new Proxy({}, {}).constructor === 'function'.

πŸ’‘ Hints (1)
  • β€’ Without a `get` trap, `.constructor` resolves on the target's prototype chain.