Skip to content
Related Articles

Related Articles

JavaScript Reflect Complete Reference

Improve Article
Save Article
  • Last Updated : 23 Nov, 2022
Improve Article
Save Article

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() MethodThe 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() MethodThe 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() MethodThe Reflect.defineProperty() method in JavaScript is used to allow the precise addition to or modification of a property on an object. 
JavaScript Reflect.deleteProperty() MethodThe 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() MethodThe 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() MethodThe Reflect.getOwnPropertyDescriptor() method in Javascript is used to get the descriptor of an object.
JavaScript Reflect.getPrototypeOf() MethodThe Reflect.getPrototypeOf() method in JavaScript is used to return the prototype of the specified object.
JavaScript Reflect.has() MethodThe 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() MethodThe Reflect.isExtensible() method in JavaScript is used to check whether an object is extensible or not. 
JavaScript Reflect.ownKeys() MethodThe 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() MethodThe 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() MethodThe Reflect.set() method in JavaScript is used to set the value of an object property.
JavaScript Reflect.setPrototypeOf() MethodThe Reflect.setPrototypeOf() method in JavaScript is used to set the prototype of a specified object to another object or to Null. 

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!