94
rated 0 times
[
100]
[
6]
/ answers: 1 / hits: 71703
/ 11 Years ago, tue, july 9, 2013, 12:00:00
How should I replace the key strings in a Javascript key:value hash map (as an object)?
This is what I have so far:
var hashmap = {aaa:foo, bbb:bar};
console.log(before:);
console.log(hashmap);
Object.keys(hashmap).forEach(function(key){
key = key + xxx;
console.log(changing:);
console.log(key);
});
console.log(after:);
console.log(hashmap);
See it running in this jsbin.
The before and after hashmaps are the same, so the forEach
seems to be in a different scope. How can I fix it? Perhaps there are better ways of doing this?
More From » javascript