JavaScript Reflect Complete Reference
JavaScript Reflect is a built-in object. Like most objects in JavaScript, it is not a constructor.
Syntax:
Reflect.function()
Example: Below examples illustrate the Reflect.setPrototypeOf() method in JavaScript:
Javascript
<script> const object1 = {}; console.log(Reflect.setPrototypeOf(object1, Object.prototype)); console.log(Reflect.setPrototypeOf(object1, null)); const object2 = {}; console.log(Reflect.setPrototypeOf(Object.freeze(object2), null)); let object3 = { gfg() { return 'value'; } } let obj = { geeks() { return 'answer'; } } Object.setPrototypeOf(obj, object3); console.dir(obj); console.log(obj.geeks()); console.log(obj.gfg());</script> |
Output:
true true false "answer" "value"
The complete list of JavaScript Reflect are listed below:
Methods:
JavaScript Reflect Method | Description |
|---|---|
| JavaScript Reflect.apply() Method | The Reflect.apply() method is a standard build-in object in JavaScript which is used to call a function using the specified argument. |
| JavaScript Reflect.construct() Method | The Reflect.construct() method in JavaScript is used to call a new target. It gives also the added option to specify a different prototype. |
| JavaScript Reflect.defineProperty() Method | The Reflect.defineProperty() method in JavaScript is used to allow the precise addition to or modification of a property on an object. |
| JavaScript Reflect.deleteProperty() Method | The Reflect.deleteProperty() method in JavaScript is used to delete a property on an object. It returns a Boolean value which indicates whether the property was successfully deleted. |
| JavaScript Reflect.get() Method | The Reflect.get() method in JavaScript is used to allow users to get the property from an object as a function. This method always returns the value of the property. |
| JavaScript Reflect.getOwnPropertyDescriptor() Method | The Reflect.getOwnPropertyDescriptor() method in Javascript is used to get the descriptor of an object. |
| JavaScript Reflect.getPrototypeOf() Method | The Reflect.getPrototypeOf() method in JavaScript is used to return the prototype of the specified object. |
| JavaScript Reflect.has() Method | The Reflect.has() method in JavaScript is used to check whether the property exists in an object or not. It works like an operator as a function. |
| JavaScript Reflect.isExtensible() Method | The Reflect.isExtensible() method in JavaScript is used to check whether an object is extensible or not. |
| JavaScript Reflect.ownKeys() Method | The Reflect.ownKeys() method in Javascript is used to return an array of the target object’s own property keys and it ignores the inherited properties. |
| JavaScript Reflect.preventExtensions() Method | The Reflect.preventExtensions() method in Javascript is used to prevent the future extensions to the object which means prevent from adding new properties to the object. |
| JavaScript Reflect.set() Method | The Reflect.set() method in JavaScript is used to set the value of an object property. |
| JavaScript Reflect.setPrototypeOf() Method | The Reflect.setPrototypeOf() method in JavaScript is used to set the prototype of a specified object to another object or to Null. |






Please Login to comment...