Implementing the Reflect API

The Reflect API is used for object reflection (that is, inspecting and manipulating the properties of objects). Although ES5 already had APIs for object reflection, these APIs were not well organized and, on failure, used to throw an exception. The Reflect API is well organized and makes it easier to read and write code, as it doesn't throw exceptions on failure. Instead, it returns the Boolean value, representing if the operation was true or false. Since developers are adapting to the Reflect API for object reflection, it's important to learn this API in depth. In this chapter, we'll cover:

  • Calling a function with a given this value
  • Invoking a constructor with the prototype property of another constructor

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.