O'Reilly logo

Rediscovering JavaScript by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Purpose of Reflect

We’ve used a few methods of Reflect so far in this book. It’s time to step back and take a fresh look at this class. Reflect has two main purposes:

  • It’s a go-to place for various meta-operations on objects. For example, Reflect provides methods to get and set the prototype of an object and to check whether a property exists in an object, just to mention a couple.

  • The Proxy class, which we’ll see soon, by default routes its methods to methods of Reflect. Then when using a proxy we can override only select operations and conveniently leave the rest to the default implementations.

There are about two dozen methods in Reflect; let’s sample a few interesting and often used methods of this class.

Invoking a Function Through Reflect ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required