What are JavaScript Proxy traps in depth?

Answer

JavaScript Proxy supports 13 traps intercepting fundamental object operations. Property access: get(target, prop, receiver) — intercept obj.prop; set(target, prop, value, receiver) — intercept obj.prop = value; has(target, prop) — intercept prop in obj; deleteProperty(target, prop). Property definition: defineProperty(target, prop, descriptor); getOwnPropertyDescriptor(target, prop). Prototype: getPrototypeOf(target); setPrototypeOf(target, proto). Extensibility: isExtensible(target); preventExtensions(target). Enumeration: ownKeys(target) — intercept Object.keys(), for...in. Functions: apply(target, thisArg, args) — intercept function calls; construct(target, args) — intercept new. Always use Reflect to forward to default behavior within traps: return Reflect.get(target, prop, receiver). The receiver ensures correct prototype chain behavior with getter properties. Proxy invariants prevent traps from breaking fundamental language contracts (e.g., you cannot make a non-configurable property appear configurable).