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

120
Vistas
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 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