🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
根据唯一值对数组进行去重 ~~~ const duplicateById = list => [...list.reduce((prev, cur) => prev.set(cur.id, cur), new Map()).values()] duplicateById([{id: 1, name: 'jack'}, {id: 2, name: 'rose'}, {id: 1, name: 'jack'}]) // [{id: 1, name: 'jack'}, {id: 2, name: 'rose'}] ~~~