The Wayback Machine - https://web.archive.org/web/20230512160051/https://www.geeksforgeeks.org/javascript-reflect-reference/
Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

JavaScript Reflect Reference

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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




<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"

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.

My Personal Notes arrow_drop_up
Last Updated : 28 Mar, 2023
Like Article
Save Article
Similar Reads
Related Tutorials