JavaScript: Reflect.getPrototypeOf

By Xah Lee. Date: . Last updated: .

New in JS2015.

Reflect.getPrototypeOf(obj)
Return the parent object. Return null if no parent. Throw a TypeError exception if obj is not a object.
console.log( 
 Reflect.getPrototypeOf ( {} ) === Object.prototype
); // true

Here is 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 Object.getPrototypeOf]

BUY
ΣJS
JavaScript in Depth

JS Obj Reference

Reflect