What's the most efficient way to search for object in an array using another object (not a function).
In javascript there is an array method .find() that accepts a callback to seek an item. How to create a similar function that accepts an object representing an object I want to find (that satisfies provided key-value conditions)? For example:
const array = [
{
param1: 'abc',
param2: 'def',
param3: 123,
},
{
param1: 'test',
param2: 'test2',
param3: 321,
},
{
param1: 'zzz',
param2: 'test2',
param3: 333,
}
]
findInArray(array, {
param1: 'test',
param2: 'test2'
}) // must return 2nd object in an array