Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!