I was wondering if there was any way in JavaScript to loop through an object like so.
(我想知道JavaScript中是否有任何方法可以像这样遍历一个对象。)
for(var i in myObject) {
// ...
}
But get the name of each property like this.
(但是这样获取每个属性的名称。)
for(var i in myObject) {
separateObj[myObject[i].name] = myObject[i];
}
I can't seem to find anything like it on Google.
(我似乎在Google上找不到类似的东西。)
They say to pass the names of the variables with them but this is not an option for what I am trying to achieve.(他们说与他们一起传递变量的名称,但这不是我想要实现的选择。)
Thanks for any help you can offer.
(谢谢你的尽心帮助。)
ask by Olical translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…