JavaScript Object.getPrototypeOf() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Object

Definition

Object.getPrototypeOf(obj) returns the prototype of obj — the object it inherits properties and methods from. If there is no prototype, the result is null.

Call it again on the result to walk up the prototype chain. This is different from a constructor’s .prototype property, which is what instances inherit from.

Syntax

Call Object.getPrototypeOf() like this. Start with this line.

JavaScript
Object.getPrototypeOf(obj)
CallWhat it does
Object.getPrototypeOf(obj)Returns the prototype of obj, or null.
Object.getPrototypeOf(Object.getPrototypeOf(obj))Moves one step further up the prototype chain.

Built into JavaScript. Call on Object — no import required.

Library declarations
JavaScript
Object.getPrototypeOf(obj)
JavaScript
getPrototypeOf(o: any): object | null;

Parameters

ParameterDescription
objRequired. The value whose prototype you want. Primitives are boxed (for example a number becomes a Number object).

Return Value

Return ValueDescription
object | nullThe prototype object, or null when the object has no prototype (for example Object.prototype or Object.create(null)).

JavaScript Examples

Example 1 — Basic Use

Check the prototypes of a plain object and an array.

JavaScript
var person = { name: "Ada" };
var list = [1, 2, 3];

console.log(Object.getPrototypeOf(person) === Object.prototype);
console.log(Object.getPrototypeOf(list) === Array.prototype);
console.log(Object.getPrototypeOf(Object.prototype));
Try It Yourself

How It Works

  1. Plain objects A normal object literal inherits from Object.prototype.
  2. Arrays Arrays inherit from Array.prototype, which then inherits from Object.prototype.
  3. End of the chain Object.prototype has no prototype, so you get null.

Example 2 — No Prototype

Objects made with Object.create(null) start with no prototype.

JavaScript
var dict = Object.create(null);
dict.color = "blue";

console.log(Object.getPrototypeOf(dict));
console.log(dict.color);
console.log(typeof dict.toString);
Try It Yourself

How It Works

  1. Create a bare object Object.create(null) makes an object with no prototype link.
  2. Own data still works You can set and read own properties like color as usual.
  3. No inherited methods There is no toString from Object.prototype, so typeof dict.toString is "undefined".

Example 3 — Walk the Chain

Follow prototypes upward until you reach null.

JavaScript
function Animal() {}
function Dog() {}
Dog.prototype = Object.create(Animal.prototype);

var rex = new Dog();
console.log(Object.getPrototypeOf(rex) === Dog.prototype);
console.log(Object.getPrototypeOf(Dog.prototype) === Animal.prototype);
console.log(Object.getPrototypeOf(Animal.prototype) === Object.prototype);
Try It Yourself

How It Works

  1. Instance link The prototype of rex is Dog.prototype.
  2. Parent link Because we set Dog.prototype with Object.create(Animal.prototype), the next step is Animal.prototype.
  3. Up to Object Function prototypes still inherit from Object.prototype unless you replace that link.

Browser & Runtime Support

Object.getPrototypeOf() has been standard since ES5. It is Baseline and available in all modern browsers.

✓ Baseline · ES5

Object.getPrototypeOf()

Supported everywhere current JavaScript runs. Prefer it over the legacy __proto__ accessor.

99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Object.getPrototypeOf Excellent

Bottom line: Safe to use in every modern project. Pair with Object.setPrototypeOf() only when necessary.

Frequently Asked Questions

It returns the prototype of an object — the object it inherits from — or null if there is no prototype.
No. getPrototypeOf(obj) reads the prototype of that value. ConstructorName.prototype is the object assigned as the prototype of new instances.
null. Those objects have no prototype and do not inherit Object.prototype methods.
No. getPrototypeOf only reads. Use Object.setPrototypeOf(obj, proto) to change it.
Object.getPrototypeOf boxes them first. For example Object.getPrototypeOf(5) returns Number.prototype.

Next: groupBy()

Split a list into groups using a callback key.

groupBy() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful