This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.
The Reflect.getPrototypeOf() static method is like Object.getPrototypeOf(). It returns the prototype of the specified object.
const object = {
foo: 42,
};
const proto = Reflect.getPrototypeOf(object);
console.log(proto);
// Expected output: Object { }
console.log(Reflect.getPrototypeOf(proto));
// Expected output: null
Reflect.getPrototypeOf(target)
targetThe target object of which to get the prototype.
The prototype of the given object, which may be an object or null.
TypeErrorThrown if target is not an object.
Reflect.getPrototypeOf() provides the reflective semantic of retrieving the prototype of an object. The only difference with Object.getPrototypeOf() is how non-object targets are handled. Reflect.getPrototypeOf() throws a TypeError if the target is not an object, while Object.getPrototypeOf() coerces it to an object.
Reflect.getPrototypeOf() invokes the [[GetPrototypeOf]] object internal method of target.
Reflect.getPrototypeOf({}); // Object.prototype
Reflect.getPrototypeOf(Object.prototype); // null
Reflect.getPrototypeOf(Object.create(null)); // null
// Same result for Objects
Object.getPrototypeOf({}); // Object.prototype
Reflect.getPrototypeOf({}); // Object.prototype
// Both throw in ES5 for non-Objects
Object.getPrototypeOf("foo"); // Throws TypeError
Reflect.getPrototypeOf("foo"); // Throws TypeError
// In ES2015 only Reflect throws, Object coerces non-Objects
Object.getPrototypeOf("foo"); // String.prototype
Reflect.getPrototypeOf("foo"); // Throws TypeError
// To mimic the Object ES2015 behavior you need to coerce
Reflect.getPrototypeOf(Object("foo")); // String.prototype
| 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 |
49 | 12 | 42 | 36 | 10 | 49 | 42 | 36 | 10 | 5.0 | 49 | 10 | 1.0.0 | 1.0 | 6.0.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/Reflect/getPrototypeOf