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

210
Vistas
How Javascript stores objects as keys

We know that

let obj1 = {};
obj1.x = "value";

let obj2 = {"key":"value"};
obj2[obj1] = "another value";
console.log(obj2[obj1]);

Above will print the "another value" properly on the console. Need to understand how. Does it store the address of obj1 for the key to match with the value?

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

0

Object property names can be strings or Symbols. Anything that is not a Symbol will be converted to a string.

A plain object's toString method will convert it to "[object Object]".

You can see that string if you log the entire object.

let obj1 = {};
obj1.x = "value";

let obj2 = {"key":"value"};
obj2[obj1] = "another value";
console.log(obj2);

console.log(obj1.toString());

This does, of course, mean that if you try to set ob2[obj3] at some point, with another object, then even if obj3 is a different object it will still be converted to the same string and overwrite the previous value.

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