JavaScript Reflect Methods

About This Index
This page is the JavaScript Reflect Methods index. The Reflect object has thirteen static methods. Each row below links to a full guide with syntax, examples you can run, and FAQs.
Learn what Reflect is on /js/reflect. Use this page when you need a specific method such as get() or defineProperty().
Write Reflect.get(obj, "a"), never obj.get("a"). The first argument is always the object you work on, and it must be a real object: a number, a string or null throws a TypeError.
How to Call a Reflect Method
Pass the object first, then the other arguments:
const user = { name: "Ann" };
Reflect.set(user, "age", 30); // true
console.log(Reflect.get(user, "age")); // 30
console.log(Reflect.has(user, "name")); // true
console.log(Reflect.ownKeys(user).join(", ")); // name, age
Reflect.deleteProperty(user, "age"); // true
console.log(Reflect.apply(Math.max, null, [1, 5, 3])); // 5 JavaScript Reflect Methods Table
All method guides in this JavaScript tutorial series (13 tutorials), grouped by what they do.
Read and write properties
4 methodsWork with the properties of an object, one at a time.
| Method | Description | Tutorial |
|---|---|---|
get() | Read the value of a property. It also finds inherited values and accepts a receiver for getters. | Open |
set() | Assign a value to a property. Returns true or false instead of throwing. | Open |
has() | Check whether a property is in an object or its prototype chain, like the in operator. | Open |
deleteProperty() | Remove a property. Returns true if it is gone and false if it could not be removed. | Open |
Define and inspect properties
3 methodsControl the flags of a property and list what an object owns.
| Method | Description | Tutorial |
|---|---|---|
defineProperty() | Add or change a property with a descriptor. Returns true or false, and never throws for a refused change. | Open |
getOwnPropertyDescriptor() | Read the value and flags (writable, enumerable, configurable) of an own property. | Open |
ownKeys() | An array of every own key, including symbols and hidden properties. | Open |
Work with prototypes
2 methodsRead and change what an object inherits from.
| Method | Description | Tutorial |
|---|---|---|
getPrototypeOf() | Return the prototype of an object, or null at the end of the chain. | Open |
setPrototypeOf() | Change the prototype. Returns false for a locked object or a loop in the chain. | Open |
Lock an object
2 methodsCheck and control whether new properties can be added.
| Method | Description | Tutorial |
|---|---|---|
isExtensible() | True if new properties can still be added to the object. | Open |
preventExtensions() | Stop new properties from being added. The change is permanent. | Open |
Call functions and create objects
2 methodsDo what the call and new syntax do, but as a method.
| Method | Description | Tutorial |
|---|---|---|
apply() | Call a function with a chosen this and an array of arguments. | Open |
construct() | Create an object from a constructor with an array of arguments, like new as a function. | Open |
Frequently Asked Questions
Start with apply()
Open the guide for calling a function with an array of arguments: syntax, examples, and FAQs.
13 people found this page helpful
