慕的地8271018
使用reduce和Object.assign合并数组中的项目:const data = [{ "Name" : "Arrow", "Year" : "2001"}, { "Name" : "Arrow", "Type" : "Action-Drama"}, { "Name" : "GOT", "Type" : "Action-Drama"}];function mergeByProp (prop, xs) { return xs.reduce((acc, x) => { if (!acc[x[prop]]) { acc[x[prop]] = x; } else { acc[x[prop]] = Object.assign(acc[x[prop]], x); } return acc; }, {});}function objToArr (obj) { return Object.keys(obj).map(key => obj[key]);}console.log(objToArr(mergeByProp('Name', data)));