[JavaScript] 纯文本查看 复制代码 const paibanArr = [
["小红", "小明", "小张", "小刘"],
["小张", "小刘", "小胡", "小楷"],
];
const menjinArr = [
{ time: "01", name: "小红" },
{ time: "01", name: "小明" },
{ time: "01", name: "小张" },
{ time: "01", name: "小刘" },
{ time: "02", name: "小张" },
{ time: "02", name: "小刘" },
{ time: "02", name: "小楷" },
];
// 由于排班表里没有日期属性,那就按照index+1当作日期来和门禁数据比对
const rs = paibanArr
.map((pbs, i) =>
pbs.filter((p) =>
menjinArr
.filter((m) => parseInt(m.time) === i + 1)
.every((m) => m.name !== p)
)
)
.flat();
console.log(rs); // [ '小胡' ] |