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:

Chrome49
Edge12
Firefox42
Opera36

Example 1

Output:

False

Example 2

Output:

"Mitzie makes a noise."

Example 3

Output:

answer
value




Latest Courses