Object.getPrototypeOf()
Returns the prototype of the specified object.
Syntax
Object.getPrototypeOf(obj) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
obj | object | Yes | The object whose prototype is returned. |
Returns
object | null — The prototype, or null if there is none.
Examples
console.log(Object.getPrototypeOf([]) === Array.prototype);
Output
true
console.log(Object.getPrototypeOf(Object.create(null)));
Output
null
Notes
The standard way to read an object's prototype (preferred over the legacy
`__proto__`). Returns null for objects created with `Object.create(null)`.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 5 |
| firefox | 3.5 |
| safari | 5 |
| edge | 12 |
| node | 0.10 |