标签:数组 each list des set class 判断 思路 lis
let t=[{id:1111,name:‘nnnn‘},{id:1111,name:‘nnnn‘},{id:1111,name:‘nnnn‘},{id:2222,name:‘mmmm‘}]; let list = []; let idList = []; t.forEach((item)=>{ if(!idList.includes(item.id)){ idList.push(item.id); idList = Array.from(new Set([...idList])); list.push(item) } });
思路:把数组对象去重用数组去重作为判断
标签:数组 each list des set class 判断 思路 lis
原文地址:https://www.cnblogs.com/holy-amy/p/11905932.html