Object

Object.getPrototypeOf

Returns the prototype of the specified object

Syntax

JavaScript
Object.getPrototypeOf(obj)

Parameters

ParameterTypeDescription
objobjectThe object whose prototype is to be returned

Return Value

The prototype of the given object, or null

Examples

Basic Usage
const arr = [1, 2, 3];
console.log(Object.getPrototypeOf(arr) === Array.prototype); // true
Practical Example
const obj = Object.create({ greet: () => 'hi' });
const proto = Object.getPrototypeOf(obj);
console.log(proto.greet()); // 'hi'
Advanced Usage
const nullProto = Object.create(null);
console.log(Object.getPrototypeOf(nullProto)); // null

Understanding Object.getPrototypeOf

The Object.getPrototypeOf method in JavaScript returns the prototype of the specified object. It belongs to the Object object and is one of the most widely used methods for working with object values in modern JavaScript and TypeScript applications.

The method signature is Object.getPrototypeOf(obj). It accepts 1 parameter: obj. When called, it returns the prototype of the given object, or null. Understanding when and how to use getPrototypeOf() helps you write more expressive, readable code.

Common use cases for Object.getPrototypeOf include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like object-setprototypeof, object-create, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Object.getPrototypeOf is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Object Methods

Other methods in the Object object

Related Tools

More Object Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.