Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

JavaScript | Reflect.getPrototypeOf() Method

  • Last Updated : 29 Sep, 2021

The Reflect.getPrototypeOf() method in JavaScript is used to return the prototype of the specified object.
Syntax: 
 

Reflect.getPrototypeOf( obj ) 

Parameters: This method accepts single parameter as mentioned above and described below: 
 

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

  • obj: This parameter is the target object and it is used to get the prototype.

Return value: This method is used to get the returned the prototype of the given object.
Exceptions: A TypeError is exception given as the result, when the target is invalid.
Below examples illustrate the Reflect.getPrototypeOf() method in JavaScript:
Example 1: 
 

javascript




<script>
const object1 = {
    property1: 356
};
 
const result = Reflect.getPrototypeOf(object1);
console.log(result);
console.log(Reflect.getPrototypeOf(result));
 
const result1 = Object.create (null); 
console.log ( 
 Reflect.getPrototypeOf ( result1 ) === null 
);  
</script>

Output: 
 



Object {  }
null
true

Example 2: 
 

javascript




<script>
console.log (Reflect.getPrototypeOf({}));      
console.log (Reflect.getPrototypeOf(Object.prototype)); 
console.log (Reflect.getPrototypeOf(Object.create(null)));
</script>

Output: 
 

Object {  }
null
null

Supported Browsers: The browsers supported by JavaScript Reflect.getPrototypeOf() Method are listed below: 
 

  • Google Chrome 49 and above
  • Edge 12 and above
  • Firefox 42 and above
  • Opera 36 and above
  • Safari 10 and above

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :