JS: Reflect.getPrototypeOf
(new in ECMAScript 2015)
Reflect.getPrototypeOf(obj)-
- Return the parent object. Return
nullif no parent. - Throw a TypeError exception if obj is not a object.
console.log(Reflect.getPrototypeOf({}) === Object.prototype); - Return the parent object. Return
Here is a example of no parent.
console.log(Reflect.getPrototypeOf(Object.create(null)) === null);
Why Reflect.getPrototypeOf
Object.getPrototypeOfconvert argument to a object first.Reflect.getPrototypeOfdoes not.