JS: Reflect.getPrototypeOf

By Xah Lee. Date: . Last updated: .

New in ES2015.

Reflect.getPrototypeOf ( obj )

Return the parent object. Return null if no parent.

Throw a TypeError exception if obj is not a object.

[see JS: Get/Set Prototype]

console.log (
 Reflect.getPrototypeOf ( {} ) === Object.prototype
); // true

Here's a example of no parent.

// create a object with no parent
const h = Object.create (null);

console.log (
 Reflect.getPrototypeOf ( h ) === null
); // true

Reflect.getPrototypeOf vs Object.getPrototypeOf

Object.getPrototypeOf ( obj ) will convert obj to a object first.

[see JS: Object.getPrototypeOf]

Reference

ECMAScript® 2016 Language Specification#sec-reflect.getprototypeof

back to JS: Reflect

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Reference
  5. DOM
  6. SVG
  7. Web Dev Blog