Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:12:13+00:00 2026-06-01T20:12:13+00:00

How Object.getPrototypeOf(obj) works? As per definition Object.getPrototypeOf(obj) should return prototype property of an Object

  • 0

How Object.getPrototypeOf(obj) works?

As per definition Object.getPrototypeOf(obj) should return prototype property of an Object or in another way it is same as obj.constructor.prototype.

Objects created with new use the value of the prototype property of their constructor function as their prototype.

Lets take an example:

>element = document.getElementById("test")

>a = Object.getPrototypeOf(element)
HTMLDivElement

Let’s say HTMLDivElement is the prototype of element.

>a.constructor.prototype
HTMLDivElement

so a.constructor.prototype is HTMLDivElement so Object.getPrototypeOf(a) should return HTMLDivElement but it returns HTMLElement. I am totally confused with definition of getPrototypeOf().

>b = Object.getPrototypeOf(a)

HTMLElement —-> why? a.constructor.prototype is HTMLDivElement

Actually it’s returning proto property of prototype, isn’t it wrong as per definition of getPrototypeOf()?

>a.constructor.prototype.__proto__
 HTMLElement
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:12:14+00:00Added an answer on June 1, 2026 at 8:12 pm

    quote from https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Inheritance_Revisited

    JavaScript is a bit confusing for developers coming from Java or C++,
    as it’s all dynamic, all runtime, and it has no classes at all. It’s
    all just instances (objects). Even the “classes” we simulate are just
    a function object.


    NOTE that prototype is also AN OBJECT, so it ALSO CAN HAVE IT’S OWN UNIQUE PROTOTYPE

    so code that make you confuse look like this

    a = Object.getPrototypeOf(element)
    b = Object.getPrototypeOf(a)
    

    can be translated to this

    a = element.__proto__
    b = element.__ptoto__.__proto__ 
    

    I think it’s now clear that a != b


    1) Every object in JavaScript has a prototype, you can access it through the __proto__ property

    2) Function is also an object in Javascript

    3) Functions also have a prototype property

    4) We can create objects in JavaScript by calling function with keyword new

    4) Function prototype is the initial __proto__ for any objects created by them


    To create new object we can write something like this

    //here we define a function
    function SomeFunctionThatCreateObject() {
        this.someStringProperty = "blablabla";
    } 
    
    var obj = new SomeFunctionThatCreateObject(); //we create new object with function
    
    var p = Object.getPrototypeOf(obj);
    

    this code is equal to this

    var SomeFunctionThatCreateObject = function(@this) {
        @this.someStringProperty = "blablabla";
        return @this;
    };
    
    SomeFunctionThatCreateObject.prototype = {}; //note that prototype is also an object
    
    var obj = {};
    
    obj = SomeFunctionThatCreateObject(obj);
    
    obj.constructor = SomeFunctionThatCreateObject;
    
    obj.__proto__ = SomeFunctionThatCreateObject.prototype;
    
    var p = obj.__proto__;
    

    PS: also read this
    https://stackoverflow.com/a/9220317/474290
    and this
    https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Inheritance_Revisited

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a difference between Object.getPrototypeOf(obj) and obj.constructor.prototype ? Or are these two referencing
Consider Object obj = ....; System.out.println(obj instanceof Object); What should obj be so that
object, contains 'array1'. $Obj -> array1 [12]; // works fine. however, dynamically generating that
Good object-oriented design says that objects should not expose their internals. Given this is
Object oriented programming in one way or another is very much possible in R.
Object Site has collection of objects Tag . Object Tag has property Title .
Using Object.Equals results in a false with two newly created objects using the same
Object.prototype.e = function() { [].forEach.call(this, function(e) { return e; }); }; var w =
Object doesn't support this property or method It's this line. pthumb = $(#pthumb).attr(src); Does
object here should refer to the Object class. As with all class identifiers in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.