title: Javascript get object key name
body: <p>How would I get the key name for the follow? E.g I want "button1" and "button2"?</p>
  
  <pre><code>var buttons = {
      button1: {
          text: 'Close',
          onclick: function(){
  
          }
      },
      button2: {
          text: 'Close2',
          onclick: function(){
  
          }
      }
  }
  
  var i;
  for(i in buttons){
      if(buttons.hasOwnProperty(i)){
          alert(buttons[i].text);
      }
  } 
  </code></pre>
  
  <p>I tried using <code>.push()</code> although this didn't work. </p>