title: Change key name in JavaScript object
body: <p>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.</p>
  
  <pre><code>var keys = Object.keys(json);
  for (var j=0; j &lt; keys.length; j++) {
     key = keys[j].replace("element_", "");
     switch(key) {
     default :
        tmp[key] = json[key];
        break;
     }
  }
  </code></pre>
  
  <p>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]).</p>
  
  <p>Is that due to the fact that I converted the keys (<code>Objects</code>) to <code>Strings</code> (with the <code>replace</code> method)?</p>