function getDisjointedObjects(a, b) {
let result = a.filter(objA => !b.some(objB => obj1.id === obj2.id));
return result;
}
// Example usage
let a = [{id: 1, name: "Alice"}, {id: 2, name: "Bob"}, {id: 3, name: "Carol"}];
let b = [{id: 2, name: "Bob"}, {id: 4, name: "David"}];
let result = getDisjointedObjects(a, b);
console.log(result);
数组取不相交部分
最新推荐文章于 2024-11-04 17:05:06 发布