Object.getPrototypeOf()

The Object.getPrototypeOf() method returns the prototype (i.e. the value of the internal [[Prototype]] property) of the specified object.

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

Using getPrototypeOf

var proto = {};
var obj = Object.create(proto);
Object.getPrototypeOf(obj) === proto; // true

Non-object coercion

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
ECMAScript (ECMA-262)
The definition of 'Object.getPrototypeOf' in that specification.

Browser compatibility

DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
getPrototypeOfChrome Full support 5Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support 12.1Safari Full support 5WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 12.1Safari iOS Full support 5Samsung Internet Android Full support 1.0nodejs 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.

See also