js 将数组里面相同的key放入同一个数组
作者:互联网
let tempList = []; let resultList = []; //filter DLQIMonthScoreWholeArray to {value+name} data["survey"].map((item)=>{ if(tempList.indexOf(item["surveyTypeID"]) === -1) { tempList.push(item["surveyTypeID"]); resultList.push({ surveyTypeID: item["surveyTypeID"], surveyQuestions: [], name:"Score", surveyType:"", series:[] }); } }) resultList.map((item) => { data["survey"].map((items) => { if (item.surveyTypeID === items.surveyTypeID) { item.surveyQuestions.push(items); item.surveyType=items["surveyType"][this.usingLanguage] } }); });
标签:map,surveyTypeID,surveyType,items,resultList,数组,js,item,key 来源: https://www.cnblogs.com/jahoon/p/15956691.html