Lesson overview · Free interview practice

Reflection

Explore advanced meta-programming concepts.

Topics in the full lesson
  • Introduction to Reflection and Metaprogramming
  • The Reflect API
  • Using Reflect Methods
  • Dynamic Property Access
  • Metaprogramming with Proxies
  • Best Practices
  • Exercises

Try the free interview questions

Work through a question before revealing its explanation. These questions and answers are free; Premium adds the full lesson walkthrough, examples and implementation detail.

TheoryEasy

The Immutability Ladder: `preventExtensions` / `seal` / `freeze`

Question

JavaScript has three increasingly strict immutability operations on an object. What does each do, and what are the corresponding is* queries?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Property Descriptors: Data vs Accessor

Question

Every property in JavaScript has a descriptor. What are the two kinds, and how do you read and define them?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

`Reflect` API for Introspection

Question

How does the Reflect API differ from the Object.* methods and the matching operators (in, delete)? When do you prefer Reflect?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Object Introspection: `keys` / `values` / `entries` / Descriptors / `Reflect.ownKeys`

Question

JavaScript has a small constellation of methods for introspecting an object's properties at runtime. What does each one cover, and when do you reach for which?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryHard

Class Introspection and Prototype Chain Walking

Question

Implement describe(cls) — walks a class hierarchy at runtime, collecting every method, getter/setter, and static, classified by where in the chain it lives.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Explore the full Reflection material

Premium includes the complete lessons and implementation references. Free practice questions remain available without a subscription.

All course tracks & premium content
From basics to advanced masterclasses
Built for JS/TS developers like you
Real-world tips & common pitfalls
Upgrade to Premium