Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda