83
JavaScript Reflect.setPrototypeOf() Method
The static Reflect.setPrototypeOf() method is used to set the prototype of a specified object to another object. The first argument is the object reference and the second argument can be either null or an object. This method is same as Object.setPrototypeOf() method.
Syntax:
Parameters:
Obj: It is the target object of which to set the prototype.
Prototype: It is the object’s new prototype.
Return value:
This method returns a Boolean which indicates whether or not the prototype was successfully set.
Exceptions:
A TypeError, if the target is not an Object
Browser Support:
Chrome | 49 |
Edge | 12 |
Firefox | 42 |
Opera | 36 |
Example 1
Output:
False
Example 2
Output:
"Mitzie makes a noise."
Example 3
Output:
answer value
Next TopicJavaScript Reflect