Object.getPrototypeOf() JavaScript

The JavaScript Object getPrototypeOf() method retrieves the prototype of the specified object. It will return null if there are no inherited properties.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Object.getPrototypeOf(object)
Object.getPrototypeOf(object)
Object.getPrototypeOf(object)

Parameters:
object: It represents the prototype of the specified object.

Return:
Prototype of the specified object.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
const proto = {};
const obj = Object.create(proto);
document.write(Object.getPrototypeOf(obj) === proto);
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> const proto = {}; const obj = Object.create(proto); document.write(Object.getPrototypeOf(obj) === proto); </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<script>
const proto = {};
const obj = Object.create(proto);
document.write(Object.getPrototypeOf(obj) === proto);
</script>
</body>
</html>