Suppose to have an array of objects, as for example:
var arr1 = [{t:new Date('2020-09-12'),NO:2},{t:new Date('2020-09-14'),NO2:20}];
var arr2 = [{t:new Date('2020-09-12'),CO:2}];
I want to filter elements of arr1 using elements of arr2 such that to exclude that with the same values of t.
I saw a similar answer, but for simple arrays, where someone suggested to use includes
.
I wonder if it is possible to use a similar approach.
I tried:
var arr1 = [{
t: new Date('2020-09-12'),
NO: 2
}, {
t: new Date('2020-09-14'),
NO2: 20
}],
arr2 = [{
t: new Date('2020-09-12'),
CO: 2
}],
res = arr1.filter(f => !arr2.includes(f.t));
console.log(res);
But it does not work. Any suggestion? Thanks in advance.