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

156
Vistas
Is the parent object reference changed if a child object is changed?

Suppose I have this

let a = { data: 'old' }

Lets say hypothetically that a has a reference to '123'

If I do

a.data = 'new'

Is the reference of a still pointing to '123' or has it been reallocated?

Thank you

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can make a very simple test for this:

let a = { data: "something" };
let b = a;

Now a and b are references to the exact same object.

a.data = "something else";
console.log(a === b); // true

Assigning to the property does not affect the value of a. Also:

console.log(b.data); // "something else"
about 4 years ago · Juan Pablo Isaza Denunciar

0

Hypothetically, if a points to '123', you can assume that a.data points to '456'.

a->123

a.data -> 456

Now when you change a.data to "new" (say now at 789), you change the pointer for a.data so a would continue to point to the old value.

a->123

a.data->789

ReactJS specific: This is the reason why when dealing with object states, react may not re-render if you change a deep object key because the parent reference does not change.

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