var a=[{name:1,key:'a'},{name:2,key:'b'},{name:3,key:'a'},{name:3,key:'b'}]
怪盗饭团
浏览 1928回答 2
2回答
慕莱坞9220042
你好:var a=[{name:1,key:'a'},{name:2,key:'b'},{name:3,key:'a'},{name:3,key:'b'}];
var result = new Array();
for(var index in a){
result[a[index].key] = new Array();
result[a[index].key].push(a[index]);
}
console.log(result);望采纳!