X = Object {A: 33, B: 76, C: 1741}
Y = { 0:Object name: A value: 33 1:Object name: A value: 76 2:Object name: C value: 1741 }
如上所述,如何在JS中的多个对象上转换一个对象? X到Y.
答案 0 :(得分:3)
var X = {A: 33, B: 76, C: 1741};
var Y = [];
for (key in X) {
Y.push({name: key, value: X[key]});
}