Reflect.getPrototypeOf() JavaScript JS

The JavaScript Reflect.getPrototypeOf() method gives the prototype of an object. It is similar to the Object.getPrototypeOf().

Syntax:

Reflect.getPrototypeOf(target)

Parameters:
target: It represents the object whose prototype have to be get.

Return:
Prototype of the specified object.

Note: It will throw TypeError, if target is not an Object.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script>
const obj = Object.create (null);  
document.write (Reflect.getPrototypeOf (obj) === null);   
</script>
</body>
</html>

Output:

true

Example 2:

<!DOCTYPE html>
<html>
<body>
<script>
 
const object1 = {
  property1: 567
};
 
const proto1 = Reflect.getPrototypeOf(object1);
 
document.write(proto1);
document.write("</br>");
 
document.write(Reflect.getPrototypeOf(proto1));
 
</script>
</body>
</html>

Output:

[object Object]
null
Please Share