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

124
Visualizações
Inconsistent javascript behavior when referencing array objects

Let's say hypothetically that we

  1. instantiated an array object
  2. referenced that array object in another array
  3. print out the array reference
  4. change the initial array's values
let initialArray = [1,2,3,4,5]
let referenceArray = [initialArray,6]
console.log(referenceArray)
initialArray.pop()

the output at chrome browser 96 Array(2) 0: (4) [1, 2, 3, 4] 1: 6 length: 2 However at nodeJs the output is [ [ 1, 2, 3, 4, 5 ], 6 ]

Why initialArray's value got popped at the browser but not nodeJs ?

Edit:
The referenced question states that it's fixed bug ,however the 10 years old question's error still persist , so it's clearly not related to such long-gone resolved bug .
Also the behavior i listed at this question only takes place when referencing another array object

let initialArray = [1,2,3,4,5] 
console.log(initialArray)
initialArray.pop()

normally outputs [1, 2, 3, 4, 5]

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