<script>
var array1 = ['2023-04-05','2023-04-06','2023-04-07']; //array1
var array2 = ['2023-04-07']; //array2
found1 = array1.find((val, index) => { //find the date in array1
return array2.includes(val);
});
$('.show').html(found1);
</script>
结果2023-04-07。怎么这样的结果2023-04-05,2023-04-06
您可以使用Array#filter
获取第一个数组中没有出现在第二个数组中的所有元素。
let array1 = ['2023-04-05','2023-04-06','2023-04-07'];
let array2 = ['2023-04-07'];
let res = array1.filter(x => !array2.includes(x));
console.log(res);