Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
But how does JavaScript mange prototype property?

let us create an empty object {} this object does have a constructor object representing the function responsible for creating the empty object and the constructor object does have a prototype object which is responsible for setting the proto for the to be created object this prototype object itself has a constructor property and so on you can go with this as far as you can (constructor > prototype > constructor > prototype > constructor > prototype > …)

the question is how does JavaScript mange all this Infinitely nested objects ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The constructor property of a constructor.prototype object is not the constructor of the prototype object but the constructor itself.

If I have a class, say A:

class A { }

And then you create an instance of A:

let a = new A();

The constructor property of a will be A. That is to say, A built a.

a.constructor === A

Which also means that:

a.constructor.prototype = A.prototype
//          A.prototype = A.prototype
//          since A === a.constructor

Now, the constructor of A.prototype is not A.prototype.constructor that would be Object (or rather it could be, you don't need a constructor to create an object really). Because the prototype of A.prototype is actually Object.prototype and the prototype of Object.prototype is null.

The prototype property of any constructor will be the prototype of their constructed objects and it's NOT the prototype of the object it belongs to.

If you keep doing:

a.prototype.constructor.prototype.constructor... you will be doing circles around the constructor prototype and the constructor itself because:

A.prototype.constructor = A
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!