I am checking the attributes in a JavaScript object, replacing some of the keys by deleting the prefix element and saving the new values in another object.
var keys = Object.keys(json);
for (var j=0; j < keys.length; j++) {
key = keys[j].replace(element_, );
switch(key) {
default :
tmp[key] = json[key];
break;
}
}
The matter is that when I do that, I can log all the keys, they have the correct names, but when I try to set the values associated to these keys, they are undefined (json[key]).
Is that due to the fact that I converted the keys (Objects
) to Strings
(with the replace
method)?