Open In App

JavaScript Reflect Reference

Last Updated : 18 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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:

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.

  • Static Method: If the method is called using the Reflect class itself then it is called a static method.
Instance Methods


Description


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


Next Article

Similar Reads