I could obviously loop the array, fetch all of the keys in each object...
Yes.
Write a function that accepts an array and a value to look for in its elements members, loop over the array, loop over the keys of the current element, and push the objects containing a member with a matching value to an array and return it after the iteration.
function findValues (arr,val) {
var result = [];
for (var i=0,current;i<arr.length;i++) {
current = arr [i];
for (var key in current) {
if (current [key] === val) {
result.push (current);
}
}
}
return result
}
Here is an example output
findValues (
[{
a:1,
b:2,
c:3
},{
a:1,
b:2,
},{
a:1,
b:2,
},{
a:1,
b:2,
c:3,
d:4
},{
a:1,
b:2,
}],
3
) //[{"a":1,"b":2,"c":3},{"a":1,"b":2,"c":3,"d":4}]