Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript | getPrototypeOf() with Examples

  • Last Updated : 17 Sep, 2021

The getPrototypeOf() is an inbuilt function in JavaScript which is used to check the prototype of an object that the user has created. Most of the times, It is used to check whether two objects have the same prototype or not. Prototype here means the internal definition of the object that is defined by the user in the JavaScript code. 


Parameters: It accepts a parameter “created_object” which is the object of the entity whose prototype going to be found out.
Return Value: It returns the internal prototype of the object passed in the method.
JavaScript code to show the working of getPrototypeOf() function: 
Code #1: 


  // Creating a simple function
  function myfun(){}
  // creating a new object
  var obj= new myfun();
  // getting the prototype


[object Object]

Code #2: 
Another application of the getPrototypeOf() function is to check whether two objects have same prototype or not 


  // Creating a simple function
  var first_var = function myFun() {};
  // Creating a object
  var second_var = Object.create(first_var);
  // Getting the output
  document.write(Object.getPrototypeOf(second_var === first_var));



Supported Browser :

  • Google Chrome 5.0 and above
  • Internet Explorer 9.0 and above
  • Firefox 3.5 and above
  • Mozilla 4.0 and above
  • Opera 12.1 and above
  • Safari 5.0 and above

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!

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!