I'm using the below code to intersect 2 very large arrays. Is it possible to improve the performance of this as it takes such a long time as it currently stands.
const arr1 = [
{
"number":"123",
"firstName":"John",
"lastName":"Smith",
"email":"test1@test.com",
},
{
"number":"1234",
"firstName":"Chad",
"lastName":"Baker",
"email":"test2@test.com",
}
];
const arr2 = [
{
"number":"12345",
"firstName":"Chad",
"lastName":"Baker",
"email":"test2@test.com",
},
{
"number":"123456",
"firstName":"John",
"lastName":"Smith",
"email":"test1@test.com",
}
]
let arr3 = arr1.filter(a => arr2.some(b => { return a.firstName == b.firstName && a.lastName == b.lastName}));
console.log(arr3);