- Reflection: the process of inspecting, managing, and modifying a program's own structure and behavior at runtime.
- Reflect
-
In JavaScript, Reflect can express the intent to manage an object's structure and behavior at runtime.
const directName = user.name; const reflectedName = Reflect.get(user, "name"); -
A proxy trap can use its corresponding Reflect method.
const proxy = new Proxy(user, { get(target, property, receiver) { console.log("get:", property); return Reflect.get(target, property, receiver); }, set(target, property, value, receiver) { console.log("set:", property); return Reflect.set(target, property, value, receiver); }, });
-
