You can make use of some
with every
to get the desired output.
const myArray = [ { id: 1, lastName: "Garland", firstName: "Darius", email: "[email protected]" }, { id: 2, lastName: "Sexton", firstName: "Collin", email: "[email protected]" } ];
const myObject = { lastName: "Sexton", email: "[email protected]" };
const result = myArray.some(k=>Object.entries(myObject).every(([key,v])=>k[key]===v));
const result2 = myArray.some(k=>Object.entries(k).every(([key,v])=>myObject[key]===v));
console.log(result);
console.log(result2);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…