1 回答
TA贡献1810条经验 获得超4个赞
拼接您正在迭代的数组将不起作用,因为所有数组索引都向下移动并且迭代会跳过移动到它刚刚检查的位置的元素。
改用filter()。
let dayArray = ["07/31/2020 1:00 AM", "08/06/2020 9:00AM", "08/06/2020 10:00AM", "08/06/2020 11:00AM", "08/06/2020 1:00PM", "08/10/2020 9:00AM", "08/10/2020 10:00AM", "08/10/2020 11:00AM", "08/10/2020 1:00PM", "08/11/2020 9:00AM", "08/11/2020 10:00AM", "08/11/2020 11:00AM", "08/11/2020 1:00PM", "08/12/2020 9:00AM", "08/12/2020 10:00AM", "08/12/2020 11:00AM", "08/12/2020 1:00PM", "08/13/2020 9:00AM", "08/13/2020 10:00AM", "08/13/2020 11:00AM", "08/13/2020 1:00PM", "08/17/2020 9:00AM", "08/17/2020 10:00AM", "08/17/2020 11:00AM", "08/17/2020 1:00PM", "08/18/2020 9:00AM", "08/18/2020 10:00AM", "08/18/2020 11:00AM", "08/18/2020 1:00PM"];
let responseArray = [{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"},{"videoTime":"07/31/2020 1:00 AM"}];
dayArray = dayArray.filter(date_time => !responseArray.find(({videoTime}) => videoTime == date_time));
console.log(dayArray);
添加回答
举报