Object.prototype.isPrototypeOf()

The chain-walking counterpart to getPrototypeOf. It asks the same question as instanceof but against a prototype object directly, which is what you need when there is no constructor to name.

Object methodES3 (1999)Live demo
Common call
proto.isPrototypeOf(obj)
Returns
boolean
Replaces
a manual getPrototypeOf loop
Watch out
the receiver is the PROTOTYPE, the argument is the object
proto.isPrototypeOf(objectobject — The object whose chain is searched. A primitive or a null always returns false rather than throwing.type: any · required)
→ boolean

Demo

Live evaluation
Try:
Inputs
jsonstringa JSON object or array
Output
(v => [Object.prototype.isPrototypeOf(v), Array.prototype.isPrototypeOf(v)])(JSON.parse('{"a":1}'))
[true, false]

The array case is the one that teaches the method. It returns [true, true] — Array.prototype is its immediate prototype, AND Object.prototype is further up the same chain. isPrototypeOf walks the whole chain rather than checking one link, which is precisely how it differs from comparing getPrototypeOf. A plain object gives [true, false] because Array.prototype appears nowhere above it.

Parameters

NameTypeRequiredDescription
objectanyyesThe object whose chain is searched. A primitive or a null always returns false rather than throwing.

Return value

boolean — True if the receiver appears ANYWHERE in the argument prototype chain — not just as its immediate prototype.

Common patterns

Check ancestry without a constructor
Where instanceof needs a function to name.
if (basePrototype.isPrototypeOf(obj)) { }
Prefer instanceof when there is a class
Clearer, and reads the way people expect.
if (obj instanceof Animal) { }
Check one link only
A direct comparison, not a chain walk.
Object.getPrototypeOf(obj) === proto;

Examples

1. Immediate prototype
Array.prototype.isPrototypeOf([])
Returns
true
2. Further up the chain
Object.prototype.isPrototypeOf([])
Returns
true
3. Unrelated
Array.prototype.isPrototypeOf({})
Returns
false
4. Agrees with instanceof
function F() {} F.prototype.isPrototypeOf(new F())
Returns
true
5. Primitives are false
Object.prototype.isPrototypeOf(42)
Returns
false
6. null is false
Object.prototype.isPrototypeOf(null)
Returns
false

Pitfalls

1. The receiver and the argument are easy to swap
It reads as "A is the prototype of B", so the PROTOTYPE goes on the left and the instance in the parentheses. Written the other way round it silently returns false rather than complaining, which makes the mistake hard to spot.
Backwards
[].isPrototypeOf(Array.prototype)
false
Correct order
Array.prototype.isPrototypeOf([])
true
2. It checks the whole chain, not one link
Object.prototype is an ancestor of almost everything, so testing against it is nearly always true and tells you very little. For "is this its immediate prototype", compare getPrototypeOf directly.
Almost always true
Object.prototype.isPrototypeOf([])
true
One link
Object.getPrototypeOf([]) === Object.prototype
false
3. It is an inherited method, so it can be shadowed
The same weakness as hasOwnProperty. An object with its own isPrototypeOf property, or one built with Object.create(null), breaks a direct call — though here the receiver is usually a prototype you control, which makes it far less dangerous in practice.
Missing on null-proto
Object.create(null).isPrototypeOf({})
TypeError: ...isPrototypeOf is not a function
Borrow it
Object.prototype.isPrototypeOf.call(proto, obj)
works
4. It is not the same question as instanceof
instanceof takes a CONSTRUCTOR and checks its .prototype property against the chain; this takes the prototype object itself. They usually agree, but instanceof can be redirected by Symbol.hasInstance and by reassigning a constructor prototype, where isPrototypeOf cannot.
Different inputs
Animal.isPrototypeOf(dog)
false — Animal is the constructor
Use its prototype
Animal.prototype.isPrototypeOf(dog)
true

When to use

Use it
  • Testing ancestry against a prototype object you hold directly
  • Code where no constructor function exists — objects built with Object.create
  • Avoiding the Symbol.hasInstance indirection that instanceof allows
Reach for something else
  • There is a class or constructor → instanceof reads better
  • You want the immediate prototype only → compare getPrototypeOf
  • You want to know if a property exists → in, or Object.hasOwn
  • The receiver may lack the method → borrow it with call

Notes

Complexity
O(d) in the depth of the prototype chain
Return
A boolean; nothing is allocated
CPython impl
V8: Builtins-object-isprototypeof
Memory
No allocation
Thread-safe
Single-threaded; only reads the chain

FAQ

instanceof whenever a constructor or class exists — it is shorter and more familiar. isPrototypeOf when you have the prototype object but no constructor, which happens with Object.create-based code and with cross-realm objects.

obj instanceof Animal;
Animal.prototype.isPrototypeOf(obj);   // the same check

History

ES3
isPrototypeOf present from early JavaScript alongside hasOwnProperty and propertyIsEnumerable.