UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ Object/ Object.getPrototypeOf()

The Object.getPrototypeOf() static method returns the prototype (i.e. the value of the internal <span class="createlink">Prototype</span> property) of the specified object.

Syntax

Object.getPrototypeOf(obj)

Parameters

Return value

The prototype of the given object, which may be null.

Examples

Using getPrototypeOf

const proto = {};
const 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

Browser compatibility

See also