Open In App

JavaScript Reflect Reference

JavaScript Reflect is a built-in object. It gives access to other methods for interceptable operations. Like most objects in JavaScript, it is not a constructor.

Syntax:



Reflect.function()

Example: Below examples illustrate the Reflect.setPrototypeOf() method in JavaScript:




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());

Output

true
true
false
{ geeks: [Function: geeks] }
answer
value

Note: There are no Properties or Contructor in Reflect Object.

The complete list of JavaScript Reflect are listed below:

String Methods: JavaScript methods are actions that can be performed on objects. There are two types of String methods in JavaScript.

Instance Methods

Description

Example

apply() Call a function using the specified argument.
Try
construct() It gives the added option to specify a different prototype.
Try
defineProperty() Allow the precise addition to or modification of a property on an object.
Try
deleteProperty() Returns a Boolean value which indicates whether the property was successfully deleted.
Try
get() This method always returns the value of the property.
Try
getOwnPropertyDescriptor() Get the descriptor of an object.
Try
getPrototypeOf() Return the prototype of the specified object.
Try
has() Check whether the property exists in an object or not. It works like an operator as a function.
Try
isExtensible() Check whether an object is extensible or not.
Try
ownKeys() Return an array of the target object’s own property keys and it ignores the inherited properties.
Try
preventExtensions() Prevent the future extensions to the object which means prevent from adding new properties to the object.
Try
set() Set the value of an object property.
Try
setPrototypeOf() Set the prototype of a specified object to another object or to Null.
Try

Article Tags :