JS数据按照字段(日期)来分组归类

let newArr = [];
data.forEach((item,i)=>{
    let index = -1;
    let isExists = newArr.some((newItem,j)=>{
        if(item.UPDATE_TIME==newItem.UPDATE_TIME){
            index = j;
            return true;
        }
    })
    if(!isExists){
        newArr.push({
            UPDATE_TIME:item.UPDATE_TIME,
            subList:[item]
        })
    }else{
        newArr[index].subList.push(item);
    }
})
原文地址:https://www.cnblogs.com/lintu-kong/p/14191786.html