摘要: const arr = [ { id: 1, parent_id: null }, { id: 2, parent_id: 1 }, { id: 3, parent_id: 1 }, { id: 4, parent_id: 2 }, { id: 5, parent_id: 4 }, ] const 阅读全文
posted @ 2021-11-23 17:57 Samsara315 阅读(645) 评论(0) 推荐(0) 编辑
摘要: const responseList = [ 1,2,2,4,5,6,1,5,3,6] console.log(uniqueBy(responseList,'a')); function uniqueBy(arr, key) { return arr.reduce((acc,cur)=>{ if ( 阅读全文
posted @ 2021-11-23 17:13 Samsara315 阅读(109) 评论(0) 推荐(0) 编辑