Name
Object.getPrototypeOf() — return the prototype of an object
Availability
ECMAScript 5
Synopsis
Object
.
getPrototypeOf
(
o
)
Arguments
o
An object.
Returns
The prototype object of o
.
Description
Object.getPrototypeOf()
returns the prototype of its argument. Note that this is a global
function, and you must pass an object to it. It is not a method that
is invoked on an object.
Example
var
p
=
{};
// An ordinary object
Object
.
getPrototypeOf
(
p
)
// => Object.prototype
var
o
=
Object
.
create
(
p
)
// An object that inherits from p
Object
.
getPrototypeOf
(
o
)
// => p
See Also
Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.