I have an array of two objects and I want to check if an array contains an object that I provide it?
I have tried this thing with array.some
as shown in the image below:
I know I can do something like:
arr.some(item => item.id === 1)
or
const objectToCompare = { id: 1, firstName: "Vishal", lastName: "Seema" };
arr.some(item => item.id === objectToCompare.id);
But I don't want to do that or compare each property as I want a generic solution when property names are not known.
Can you suggest a way for full object comparison?