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

290
Visualizações
How reference value types in Javascript works?

I'm learning Javascript, based on my knowledge that the reference type like object below is created in the heap, and point to a new piece of memory in the stack. But what happened when I've tried to declare an object like this:

let object = { id: 1223, title: 'test' };

and when I reassigned it:

object = { newId: object.id, newTitle: object.title };

I got:

object = { newId: 1223, newTitle: 'test' };

I'm so curious as to why this is possible, Has the property name gone when I reassigned the object? and How it works behind the screen?

Please give me some explanations, keywords, or documents.

Many thanks.

P/s. Something I forgot is that the = operator's associativity happened from right to left, so the object at this point was not mutated until the execution met the =. Maybe it is the answer for my question somehow.

about 4 years ago · Juan Pablo Isaza
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