The array of objects to check within.
The object to find within the array.
Optional
returnType: boolean = falseIf true, returns the found object; otherwise, returns a boolean indicating presence.
const objArr = [{ id: 1, name: 'John' }, { id: 2, name: 'Jane' }];
const data = { id: 1, name: 'John' };
const result_1 = hasObj(objArr, data);
console.log(result_1); // true
const result_2 = hasObj(objArr, data, true);
console.log(result_2); // { id: 1, name: 'John' }
Generated using TypeDoc
Checks if a given object is within an array of objects. Checks for object equality using the
compareObject
function.