Let's say I have the following array containing arrays of objects (songs):
[
  [
    {
      name: 'I Want You Back',
      id: 1
    },
    {
      name: 'ABC',
      id: 2
    }
  ],
  [
    {
      name: 'I Want You Back',
      id: 1
    },
    {
      name: 'Dont Stop Me Now',
      id: 3
    }
  ],
  [
    {
      name: 'I Want You Back',
      id: 1
    },
    {
      name: 'ABC',
      id: 2
    }
  ],
]
I wish to go through my data and return the objects that have been found in every array, so in this case, the returning value would be:
{
   name: 'I Want You Back',
   id: 1
}
So far, I've only managed to do it for arrays of strings, not objects, like so:
const arrays = [
  ['I Want You Back', 'ABC'],
  ['I Want You Back', 'Dont stop me now'],
  ['I Want You Back', 'ABC']
];
const result = arrays.shift().filter((v) => {
  return arrays.every((a) => {
    return a.indexOf(v) !== -1;
  });
});
// result = ["I Want You Back"]
I've been trying, but I can't manage to apply the same logic with my objects (and their name or id for example). I'd really appreciate if some of you show me how you would do it.
 
    