Object.getPrototypeOf
Returns the prototype of the specified object
Syntax
Object.getPrototypeOf(obj)Parameters
| Parameter | Type | Description |
|---|---|---|
| obj | object | The object whose prototype is to be returned |
Return Value
The prototype of the given object, or null
Examples
const arr = [1, 2, 3];
console.log(Object.getPrototypeOf(arr) === Array.prototype); // trueconst obj = Object.create({ greet: () => 'hi' });
const proto = Object.getPrototypeOf(obj);
console.log(proto.greet()); // 'hi'const nullProto = Object.create(null);
console.log(Object.getPrototypeOf(nullProto)); // nullUnderstanding 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.