The Reflect API
Forward operations with Reflect methods.
What Is Reflect?
Reflect is a built-in object with methods that perform the default low-level operations on objects: getting, setting, deleting, and more.
Its methods mirror the proxy traps one-to-one, which makes it the ideal partner for writing correct proxies.
Reflect.get
Reflect.get(target, prop) reads a property, the same as target[prop], but as a clean function call.
const obj = { name: 'Ada', age: 36 };
console.log(Reflect.get(obj, 'name'));
console.log(Reflect.get(obj, 'age'));All lessons in this course
- Creating a Proxy
- get and set Traps
- The Reflect API
- Practical Proxy Use Cases