手写loadsh函数的第二天
<script>
const arr = [
{ x: 1, y: 2 },
{ x: 2, y: 1 },
];
function differenceWith(array, values, comparator) {
return array.filter((item) =>
values.every((val) => !comparator(item, val))
);
}
console.log(
differenceWith(
arr,
[{ x: 1, y: 2 }],
(a, b) => a.x === b.x && a.y === b.y
)
);
</script>