This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The Object.getPrototypeOf() static method returns the prototype (i.e., the value of the internal [[Prototype]] property) of the specified object.
const prototype = {};
const object = Object.create(prototype);
console.log(Object.getPrototypeOf(object) === prototype);
// Expected output: true
Object.getPrototypeOf(obj)
objThe object whose prototype is to be returned.
The prototype of the given object, which may be null.
const proto = {};
const obj = Object.create(proto);
Object.getPrototypeOf(obj) === proto; // true
In ES5, it will throw a TypeError exception if the obj parameter isn't an object. In ES2015, the parameter will be coerced to an Object.
Object.getPrototypeOf("foo");
// TypeError: "foo" is not an object (ES5 code)
Object.getPrototypeOf("foo");
// String.prototype (ES2015 code)
| Desktop | Mobile | Server | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | Bun | Deno | Node.js | |
getPrototypeOf |
5 | 12 | 3.5 | 12.1 | 5 | 18 | 4 | 12.1 | 5 | 1.0 | 4.4 | 5 | 1.0.0 | 1.0 | 0.10.0 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf