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.
But the below is returning false, suggesting they are not equivalent?
console.log(keyArray[25] === keyArray[27]);
Interested to understand what can cause that.