Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda