The Object.getPrototypeOf() method returns the prototype (i.e. the value of the internal [[Prototype]] property) of the specified object.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
Object.getPrototypeOf(obj)
Parameters
obj- The object whose prototype is to be returned.
Return value
The prototype of the given object. If there are no inherited properties, null is returned.
Examples
var proto = {};
var obj = Object.create(proto);
Object.getPrototypeOf(obj) === proto; // true
Notes
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)
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 5.1 (ECMA-262) The definition of 'Object.getPrototypeOf' in that specification. |
Standard | Initial definition. |
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Object.getPrototypeOf' in that specification. |
Standard | |
| ECMAScript Latest Draft (ECMA-262) The definition of 'Object.getPrototypeOf' in that specification. |
Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getPrototypeOf | Chrome Full support 5 | Edge Full support 12 | Firefox Full support 3.5 | IE Full support 9 | Opera Full support 12.1 | Safari Full support 5 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
Legend
- Full support
- Full support
Opera-specific notes
Even though older Opera versions don't support Object.getPrototypeOf() yet, Opera supports the non-standard __proto__ property since Opera 10.50.