It seems like there may be some confusion about whether you are looking to work with arrays or objects based on your example of single element arrays and the comparison being made between the objects within them.
If your intention is to compare two objects and find the keys that are the same in both, a simple function like the one below could achieve that:
let firstObject = {apple: 1, orange: 2, banana: 3};
let secondObject = {apple: 2, orange: 5, banana: 3};
function findMatchingKeys(x, y) {
return Object.keys(x).filter(function(key) {
return x[key] === y[key];
});
}
console.log(findMatchingKeys(firstObject, secondObject));
Upon running this code, the output should be:
[ 'banana' ]
I hope this clears up any confusion you had regarding the comparison of objects in JavaScript.