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

206
Vistas
Cannot get value in JS object and overwriting the key adds a duplicate

The object data is from a .NET backend API. I log the output in JS.

24 console.log(data["Approved Variations"]);
25 data["Approved Variations"] = "Approved Elephants";
26 console.log(data["Approved Variations"]);
27 console.log(data);

The first key's value is undefined. I add it, but the expected key exists when inspecting the data.

ProjectLocalization.js:24 undefined
ProjectLocalization.js:26 Approved Elephants
ProjectLocalization.js:27 {
Approved Variations: "Approved Elephants"
Variations: "Variations"
Approved Variations: "Approved Cats"
}

Why can I not get the key's value, and why are there now duplicate keys? Does this suggest the key name is somehow encoded differently? It only appears to happen for keys with a space in the name.

UPDATE

When I console.log the array of keys, I get the below, which to the naked eye appears identical.

enter image description here

But the below is returning false, suggesting they are not equivalent?

    console.log(keyArray[25] === keyArray[27]);

Interested to understand what can cause that.

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