一个数组中去除某一部分数组


let arr = ['q', 'w', 'e', 'r', 't', 'y'];
let aaa = ['q', 'y'];
arr = arr.filter(item => !aaa.some(aaaItem => aaaItem === item));
console.log(arr)  //["w", "e", "r", "t"]
 
 
let a = [{name:'gaojiarui',age:'18',id:'1231'},{name:'gjr',age:'16',id:'1324'},{namg:'gqjr',age:'17',id:'1234'}];
let b = [{name:'gjr',id:'1324'},{name:'gqjr',id:'1234'}]

a = a.filter(item => !b.some(aa => aa.id === item.id))
console.log(a);  //[{name: "gaojiarui", age: "18", id: "1231"}]

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM