筛选两个数组间相同的数据
1.筛选两个数组
let initList = [1, 2, 35, 15, 48, 68, 48, 52];
let list = [35, 68];
console.log(initList.filter((item) => list.some((val) => val == item)));
结果
2.根据对象某个属性筛选对应的数组对象
let initList = [{id:2,name:"hello"},{id:12,name:"world"},{id:32,name:"ni"},{id:35,name:"hao"},{id:23,name:"世界"}];
let list = [2, 23];
console.log(initList.filter((item) => list.some((val) => val == item.id)));
标签:name,val,list,JS,item,let,操作,id From: https://www.cnblogs.com/TwoBamboo/p/16783624.html结果