Home

ObjectgetPrototypeOf

Object.getPrototypeOf is a built-in JavaScript function that retrieves the prototype of a given object. It is a static method on the Object constructor and is defined by the ECMAScript 5 standard. The prototype retrieved is the value of the object's internal [[Prototype]] slot, which underpins property inheritance in JavaScript objects.

Syntax and behavior: Object.getPrototypeOf(object) returns the object's immediate prototype. If the argument is a primitive value,

Examples: Object.getPrototypeOf({}) yields Object.prototype; Object.getPrototypeOf([]) yields Array.prototype; Object.getPrototypeOf(function(){}) yields Function.prototype. For an object created with no

Usage notes: Object.getPrototypeOf is the standard and recommended way to inspect an object's prototype. It is

Compatibility: Introduced in ES5 and supported by all modern browsers and Node.js versions.

it
is
boxed
to
its
wrapper
object
and
the
wrapper's
prototype
is
returned.
If
the
argument
is
null
or
undefined,
the
call
throws
a
TypeError
because
null
and
undefined
do
not
have
a
prototype.
prototype,
such
as
Object.create(null),
Object.getPrototypeOf(obj)
returns
null.
preferred
over
the
deprecated
__proto__
property
and
can
be
used
to
test
inheritance
with
strict
equality
checks
(e.g.,
objProto
===
SomePrototype).
Related
functions
include
Object.setPrototypeOf
and
Object.create.