The Object.getPrototypeOf()
method returns the prototype (i.e. the value of the internal [[Prototype]]
property) of the specified object.
Object.getPrototypeOf()
Try it
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
Specifications
Browser compatibility
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | Deno | Node.js | |
getPrototypeOf |
5
|
12
|
3.5
|
9
|
12.1
|
5
|
1
|
18
|
4
|
12.1
|
5
|
1.0
|
1.0
|
0.10.0
|
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
© 2005–2022 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf