我希望得到一个数组,看起来像这样的价值观:获取名称和值从阵列中的Javascript
t = new Object();
t.erg = new Array();
t.erg['random1'] = "something1";
t.erg['random2'] = "something2";
t.erg['random3'] = "something3";
t.erg['random4'] = "something4";
但我想通过一个循环,让他们的随机的名字,然后值,我无法找到一个方法来做到这一点:/
的[如何列出一个JavaScript对象的属性]可能重复(http://stackoverflow.com/questions/208016/how-to-list-the-properties-of -a-JavaScript的对象)。 NB,[你正在使用'Array'错误地](http://andrewdupont.net/2006/05/18/javascript-associative-arrays-considered-harmful/)。 –