JavaScript Reflect setPrototypeOf() Method Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report JavaScript Reflect.setPrototypeOf() method in JavaScript is used to set the prototype of a specified object to another object or to Null. This method returns the boolean value for the operation that is successful. This method is the same as the Object.setPrototypeOf() method. Syntax: Reflect.setPrototypeOf(obj, prototype) Parameters: Obj: This parameter holds the target object and it is used to set the prototype.Prototype: This parameter holds the object's new prototype. It can be any object or simply a null. Return value: This method always returns a Boolean value which indicates whether setting the prototype was successfully done or not. Exceptions: A TypeError is an exception given as the result when the target is not an object. Below examples illustrate the Reflect.setPrototypeOf() method in JavaScript: Example 1: In this example, we will set the prototype of an object using 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 "answer" "value" Example 2: In this example, we will set the prototype of an object using the Reflect.setPrototypeOf() method in JavaScript. javascript console.log(Reflect.setPrototypeOf({}, Object.prototype)); // It can change an object's [[Prototype]] to null. console.log(Reflect.setPrototypeOf({}, null)); // Returns false if target is not extensible. console.log(Reflect.setPrototypeOf(Object.freeze({}), null)); // Returns false if it cause a prototype chain cycle. let target = {} let proto = Object.create(target) console.log(Reflect.setPrototypeOf(target, proto)); let object3 = { gfg() { console.log(this.name + ' have fun.'); } }; class objt { constructor(name) { this.name = name; } } Reflect.setPrototypeOf(objt.prototype, object3); // If you do not do this you will get // a TypeError when you invoke speak let val = new objt('Geeks'); val.gfg(); Output: true true false false "Geeks have fun." Supported Browsers: The browsers supported by JavaScript Reflect.setPrototypeOf() method are listed below: Google Chrome 49 and aboveEdge 12 and aboveFirefox 42 and aboveOpera 36 and aboveSafari 10 and above We have a complete list of Javascript Reflects methods, to check those go through the JavaScript Reflect Reference article. Comment More infoAdvertise with us Next Article JavaScript Reflect apply() Method S SHUBHAMSINGH10 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Methods JavaScript-Reflect Similar Reads JavaScript Reflect apply() Method Javascript Reflect.apply() method is a standard build-in object in JavaScript which is used to call a function using the specified argument. It works similar to the Function.prototype.apply() method to call a function, but in an efficient manner and easy to understand. Syntax: Reflect.apply(target, 2 min read JavaScript Reflect construct() Method JavaScript Reflect.construct() method in JavaScript is used to call a new target. It gives also the added option to specify a different prototype. Syntax: Reflect.construct(para1, para2, para3)Parameters: This method accepts three parameters as mentioned above and described below: para1: This parame 2 min read JavaScript Reflect defineProperty() Method JavaScript Reflect.defineProperty() method in JavaScript is used to allow the precise addition to or modification of a property on an object. This method returns a Boolean value which indicates whether the property was successfully defined. Syntax: Reflect.defineProperty(target, propertyKey, attribu 2 min read JavaScript Reflect deleteProperty() Method JavaScript 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. Syntax: Reflect.deleteProperty( target, propertyKey ) Parameters: This method accepts two parameters as mentio 2 min read JavaScript Reflect get() Method JavaScript 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. Syntax: Reflect.get(target, propertyKey, receiver) Parameters: This method accepts three parameters as mentioned above and desc 2 min read JavaScript Reflect getOwnPropertyDescriptor() Method JavaScript Reflect.getOwnPropertyDescriptor() method in Javascript is used to get the descriptor of an object if it exists in the object. It is the same as the Object.getOwnPropertyDescriptor method, but non-object targets are handled differently. Syntax: Reflect.getOwnPropertyDescriptor(obj, Key) P 2 min read JavaScript Reflect getPrototypeOf() Method JavaScript Reflect.getPrototypeOf() method in JavaScript is used to return the prototype of the specified object. Syntax: Reflect.getPrototypeOf( obj ) Parameters: This method accepts a single parameter as mentioned above and described below: obj: This parameter is the target object and it is used t 2 min read JavaScript Reflect has() Method JavaScript Reflect.has() method in JavaScript is used to check whether the property exists in an object or not. It works like the in operator as a function. Syntax: Reflect.has(target, propertyKey) Parameters: This method accepts two parameters as mentioned above and described below: target: This pa 2 min read JavaScript Reflect isExtensible() Method JavaScript Reflect.isExtensible() method in JavaScript is used to check whether an object is extensible or not(Checks whether other properties can be added to it or not). This method is similar to Object.isExtensible() but it will cause a TypeError if the target is not an object. Syntax: Reflect.isE 2 min read JavaScript Reflect ownKeys() Method JaScript 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. Syntax: Reflect.ownKeys( obj ) Parameters: This method accepts a single parameter as mentioned above and described below: Obj: This parameter h 2 min read Like