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

144
Visualizações
Are object variables with the same address always identical in JavaScript?

This question seems a bit silly but I just wanna confirm my understanding.

  1. I'm learning about comparision in JavaScript and it seems to me that if two ojbects have the same address then they should definitely be equal (b/c basically they are one?). Is this always true?

  2. bonus question: in the case I do want to implement this address comparision (shallow comparision), can I do it in pure JS without Object.is or ===?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Two objects cannot occupy the same location, either in our physical universe or in the twisted javascript universe. What you can have are two objects whose values are references to the same memory location.

var x = [1, 2, 3]
var y = x

So, the array [1, 2, 3] might be stored in some memory address, let's say it starts at 00A4. The variable x will be stored in some different place in memory, let's say 0108, and the actual value stored in that location is the number 00A4, that represents the memory location of its referenced value. Now, y will be then store in another totally different memory location, let's say 020F, and its value will also be 00A4, the memory location of its referenced value.

  1. Both x and y are variables whose values are references, that ultimately point to the same address. Reference values that point to the same address are always equal when compared.

  2. Javascript doesn't have any low-level semantics like this to manipulate memory addresses. You could do that maybe by using c procedure calls or something.

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