一个数组arr = [{"id":1393,"sort":3},{"id":1395,"sort":4},{"id":1397,"sort":5}]根据sort=4拆分成两个数组arr1 = [{"id":1393,"sort":3},{"id":1397,"sort":5}];arr2=[{"id":1395,"sort":4}]
1 回答
DIEA
TA贡献1820条经验 获得超3个赞
arr1 = arr.filter((elem,index)=> elem.sort != 4)
arr2 = arr.filter((elem,index)=> elem.sort == 4)
添加回答
举报
0/150
提交
取消
