JS:
var datas=[
{name:'的风格',value:'25',type:'地图'},
{name:'但是',value:"35",type:'编程'},
{name:'让国人',value:'11',type:'地图'},
{name:'无关的方法',value:'24',type:'接口'},
{name:'大幅波动',value:"65",type:'编程'},
]
var map = {},
dest = [];
for (var i = 0; i < datas.length; i++) {
var ai = datas[i];
if (!map[ai.type]) {
dest.push({
type: ai.type,
name: [ai.name],
value: [ai.value],
});
map[ai.type] = ai;
//console.log(map[ai.FUNDSNAME])
} else {
for (var j = 0; j < dest.length; j++) {
var dj = dest[j];
if (dj.type == ai.type) {
dj.name.push(ai.name);
dj.value.push(ai.value);
break;
}
}
}
}
console.log(dest)
效果: