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

207
Visualizações
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 à 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