问题描述
初衷是根据把相同id的对象丢到一个新数组里,然后如果遇到id不同的就停止,如此反复
相关代码
arr = [
{id:1,name:'a'},
{id:1,name:'a1'},
{id:1,name:'a2'},
{id:2,name:'b'},
{id:1,name:'c'},
{id:2,name:'d'},
{id:2,name:'d1'},
{id:1,name:'e'}
]
想根据id拆分成如下数组
arr1 = [{id:1,name:'a'},{id:1,name:'a1'},{id:1,name:'a2'}]
arr2 = [{id:2,name:'b'}]
arr3 = [{id:1,name:'c'}]
arr4 = [{id:2,name:'d'},{id:2,name:'d1'}]
arr5 = [{id:1,name:'e'}]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…