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 has to be obtained.

Return:
Prototype of the specified object.

Note: It will throw a TypeError if the 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>

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>