Documentación offline JavaScript main

Object.getPrototypeOf()

main Documentación oficial Licencia CC-BY-SA-2.5Descargado el 2026-08-02

En esta página

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

{{InteractiveExample("JavaScript Demo: Object.getPrototypeOf()", "shorter")}}

```js interactive-example const prototype = {}; const object = Object.create(prototype);

console.log(Object.getPrototypeOf(object) === prototype); // Expected output: true

## Syntax

```js-nolint
Object.getPrototypeOf(obj)

Parameters#

  • obj
  • : The object whose prototype is to be returned.

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 {{jsxref("TypeError")}} exception if the obj parameter isn't an object. In ES2015, the parameter will be coerced to an {{jsxref("Object")}}.

Object.getPrototypeOf("foo");
// TypeError: "foo" is not an object (ES5 code)
Object.getPrototypeOf("foo");
// String.prototype                  (ES2015 code)

Specifications#

{{Specifications}}

Browser compatibility#

{{Compat}}

See also#