What is a Proxy? What are traps, and how does Reflect complement it? Give a real use case.
Metaprogramming: intercepting fundamental object operations and forwarding default behavior correctly.
A Proxy wraps a target object and lets you intercept fundamental operations via handler functions called traps — get, set, has, deleteProperty, apply, construct, and more. Reading, writing, or calling through the proxy runs your trap instead of (or before) the default behavior. Reflect is the companion: it exposes those same operations as plain functions (Reflect.get, Reflect.set, ...) whose signatures mirror the traps exactly, so inside a trap you call the matching Reflect method to perform the default operation and return its result — this is cleaner and more correct than target[key], especially for preserving the right receiver so inherited getters/setters bind to the proxy. Real use cases: reactive state (Vue 3's reactivity is Proxy-based — a set trap notifies subscribers), validation/schema enforcement on assignment, negative array indexing, default values for missing keys, logging/tracing, and access control. Caveats: proxies add per-operation overhead, cannot be fully transparent (you can detect them), and some invariants can't be violated. Reach for a Proxy only when you genuinely need to intercept operations generically; a getter/setter or a plain wrapper is simpler when the surface is small.
Reactive stores, validation-on-write, default/computed properties, API mocking, and cross-cutting logging without touching call sites.
Adds a trap-call overhead to each intercepted operation.