Reflect — Complete Guide
Reflect — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of JavaScript Tutorial on Toolliyo Academy.
On this page
JavaScript Tutorial · Lesson 63 of 100
Reflect
Basics ✓ → Objects & data ✓ → Async & DOM ✓ → Advanced → Tools → Projects
Advanced · 4 — Production skills · ~10 min · JS Advanced
What is this?
Reflect provides methods that match Proxy traps — get, set, apply — with consistent behavior.
Why should you care?
Default forward behavior in proxies: return Reflect.get(target, key).
See it live — copy this example
Paste into an HTML file or the browser console (F12). Use Run below when the live editor is available.
const obj = { x: 1 };
console.log(Reflect.get(obj, "x"));
Reflect.set(obj, "y", 2);
console.log(obj);
Run Example »
Edit the code below and click Run to see the result in Toolliyo’s live editor.
What happened?
- Reflect methods do what the language would do by default — useful inside proxy traps.
Practice next
- Use Reflect.get and Reflect.set on plain object.
- Inside Proxy set trap return Reflect.set(target, key, value).
- Compare Reflect.has with in operator.
- Build deleteProperty trap that forwards Reflect.deleteProperty.
- Use Reflect.apply to call a function with dynamic this.
Remember
Mirror object operations Use inside Proxy traps Cleaner than target[key] in traps
ScriptVerse validation layer
Proxy set trap uses Reflect.set only after validation passes, otherwise returns false.
Outcome: Reflect gives consistent defaults inside custom meta-programming traps.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!