Javascript получить имя ключа объекта
Как бы я получить ключевое имя для последующего? Например, я хочу & quot; кнопку1 & quot; и & quot; button2 & quot ;?
<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>
Я пытался с помощью.push()
хотя это не сработало.