JavaScript Reflect.getPrototypeOf() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
Static method

Definition

Reflect.getPrototypeOf(target) returns the prototype of an object: the object that it inherits properties and methods from. For an array this is Array.prototype, and for an object made with a class it is that class's prototype.

If the object has no prototype, you get null. By calling the method again on the result, you can walk up the whole prototype chain until you reach null.

Remember
Reflect.getPrototypeOf(target)

returns the prototype object, or null

Reflect.getPrototypeOf([])  → Array.prototype
Reflect.getPrototypeOf({})  → Object.prototype
The end of every chain      → null

target must be an object, or TypeError

Syntax

Pass an object. Compare the result with the prototype you expect.

JavaScript
const list = [1, 2, 3];

const proto = Reflect.getPrototypeOf(list);

console.log(proto === Array.prototype);   // true
console.log(Reflect.getPrototypeOf(proto) === Object.prototype);   // true
CallWhat it does
Reflect.getPrototypeOf(obj)The prototype of obj, or null.
Reflect.getPrototypeOf(Reflect.getPrototypeOf(obj))Go one level further up the chain.
Reflect.setPrototypeOf(obj, proto)Change the prototype of an object.
Object.getPrototypeOf(obj)The older version. It also accepts primitives.

A standard JavaScript static method (ES2015) of the Reflect object: call it as Reflect.getPrototypeOf(). No import required. Siblings: Reflect.apply(), Reflect.construct(), Reflect.defineProperty(), Reflect.deleteProperty(), Reflect.get(), Reflect.getOwnPropertyDescriptor(), Reflect.has(), Reflect.isExtensible(), Reflect.ownKeys(), Reflect.preventExtensions(), Reflect.set(), Reflect.setPrototypeOf().

Library declarations
JavaScript
// ECMAScript 2015 (ES6)
Reflect.getPrototypeOf(target)

// target : an object
// returns: the prototype object, or null
// throws : TypeError if target is not an object

Parameters

ParameterDescription
targetRequired. The object whose prototype you want. If it is not an object, a TypeError is thrown.

Return Value

Return ValueDescription
ObjectThe prototype of target.
nulltarget has no prototype, for example an object made with Object.create(null), or the end of a prototype chain.
TypeError (thrown)target is not an object.

JavaScript Examples

Example 1 — Find the Prototype of an Object

Check the prototype of an array, a plain object, a function and an object that has no prototype.

JavaScript
console.log("Array: " + (Reflect.getPrototypeOf([]) === Array.prototype));
console.log("Object: " + (Reflect.getPrototypeOf({}) === Object.prototype));
console.log("Function: " + (Reflect.getPrototypeOf(function () {}) === Function.prototype));

const bare = Object.create(null);
console.log("No prototype: " + Reflect.getPrototypeOf(bare));
Try It Yourself

How It Works

  1. Built-in types. Each kind of value has a matching prototype: arrays use Array.prototype, plain objects use Object.prototype, and functions use Function.prototype.
  2. Compare with ===. The prototype is an object, so you compare it by identity with the one you expect.
  3. No prototype at all. Object.create(null) makes an object without a prototype, so you get null.

Example 2 — Prototypes of Classes

Create a small class family and see how the prototypes are connected.

JavaScript
class Animal {}
class Dog extends Animal {}

const rex = new Dog();

console.log("Instance: " + (Reflect.getPrototypeOf(rex) === Dog.prototype));
console.log("Dog.prototype: " + (Reflect.getPrototypeOf(Dog.prototype) === Animal.prototype));
console.log("Class Dog: " + (Reflect.getPrototypeOf(Dog) === Animal));
console.log("Class Animal: " + (Reflect.getPrototypeOf(Animal) === Function.prototype));
Try It Yourself

How It Works

  1. Instance to class. The prototype of rex is Dog.prototype, the object that holds the methods of Dog.
  2. Up to the parent. The prototype of Dog.prototype is Animal.prototype, because Dog extends Animal.
  3. Classes are objects too. The prototype of the class Dog itself is Animal, which is how static methods are inherited. The class Animal has Function.prototype.

Example 3 — Walk Up the Prototype Chain

Repeat getPrototypeOf() in a loop until null. Then see that primitives are not accepted. The catch block prints the error type only.

JavaScript
const names = [];
let current = Reflect.getPrototypeOf([1, 2, 3]);

while (current !== null) {
  names.push(current.constructor.name);
  current = Reflect.getPrototypeOf(current);
}
console.log("Chain: " + names.join(" -> "));

try {
  Reflect.getPrototypeOf(5);
} catch (err) {
  console.log("Reflect with a number: " + err.name);
}
console.log("Object with a number: " + (Object.getPrototypeOf(5) === Number.prototype));
Try It Yourself

How It Works

  1. Loop to the end. The code reads the prototype again and again until it gets null, and saves the name of each constructor on the way.
  2. The chain of an array. An array inherits from Array.prototype, which inherits from Object.prototype, which has no prototype.
  3. Primitives. Reflect.getPrototypeOf(5) throws a TypeError, while Object.getPrototypeOf(5) quietly wraps the number and returns Number.prototype.

Browser & Runtime Support

Reflect.getPrototypeOf() is part of ES2015 (ES6), together with the Reflect object. Every current browser and Node.js has it.

✓ ES2015 · Widely supported

Reflect.getPrototypeOf()

Supported in Chrome 49+, Edge 12+, Firefox 42+, Safari 10+, Opera 36+ and Node.js 6+. Internet Explorer never got it.

ES2015 Standard since
Google Chrome 49+ · Desktop & Mobile
Full support
Microsoft Edge 12+ · Chromium and legacy
Full support
Mozilla Firefox 42+ · Desktop & Mobile
Full support
Apple Safari 10+ · macOS & iOS
Full support
Opera 36+ · Chromium based
Full support
Samsung Internet Recent versions · Android
Supported
Android WebView 49+ · Chromium based
Supported
Node.js 6+ · Server runtime
Supported
Deno Supported · JavaScript runtime
Supported
Bun Supported · JavaScript runtime
Supported
Internet Explorer No native support
Not supported
Reflect.getPrototypeOf() Excellent

Bottom line: Safe to use in every current browser and in Node.js. The only thing to plan for is Internet Explorer, which has no Reflect at all.

Frequently Asked Questions

It returns the prototype of an object, the object that it inherits from. If the object has no prototype, it returns null.
For objects they give the same result. Object.getPrototypeOf() accepts primitives and converts them to objects first. Reflect.getPrototypeOf() throws a TypeError when the target is not an object.
It is the list of objects that JavaScript searches when you read a property. If the object does not have it, JavaScript looks at its prototype, then at the prototype of that, and so on until null. Reflect.getPrototypeOf() lets you walk this list.
No. Every object has a prototype that you read with getPrototypeOf(). Only functions and classes have a prototype property, which is the object their instances will inherit from.
Because some objects have no prototype. Object.prototype is at the end of the normal chain and has none, and Object.create(null) makes a new object without one.

Next: Reflect.has()

Learn how to check whether a property is in an object, like the in operator but as a function.

Reflect.has() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful