我有一个对象样本data
:
[Object, Object, Object]
0: Object
test_id: "1"
area: "high"
1: Object
test_id: "1"
area: "saw"
2: Object
test_id: "2"
area: "look"
我正在尝试通过分组来创建一个新对象test_id
。
var obj = new Object();
$.each(data, function(k, v){
obj[v.test_id] += {area: v.area};
});
这似乎不起作用,它只返回一个对象线......
我想得到类似的东西:
1: {
{area: "high"}
{area: "saw"}
}
2: {
{area: "look""
}
有任何想法吗?谢谢