GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

Object.getPrototypeOf()

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

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

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`](/docs/Web/JavaScript/Reference/Operators/null).

## Examples

### Using getPrototypeOf

```js
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.

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

## Specifications

## Browser compatibility

## See also

- [Polyfill of `Object.getPrototypeOf` in `core-js`](https://core-js.io/docs/features/ecmascript/object)
- [es-shims polyfill of `Object.getPrototypeOf`](https://www.npmjs.com/package/object.getprototypeof)
- Object.prototype.isPrototypeOf()
- Object.setPrototypeOf()
- [`Object.prototype.__proto__`](/docs/Web/JavaScript/Reference/Global_Objects/Object/proto)
- Reflect.getPrototypeOf()
- [Object.getPrototypeOf](https://johnresig.com/blog/objectgetprototypeof/) by John Resig (2008)

source: MDN Web Docs mirror · page

Cite this

"Object.getPrototypeOf()". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·