There is an array containing multiple sub-arrays, each with some elements.
For example:
const myArray = [[1,2,3],[2,3,4,5,6,7],[2,3,4],[2,3,6,11]];
in this case it should return [2,3]
as these are the common elements in all sub-arrays.
Is there an efficient way to do that?
I wrote a function that does it for 2 sub-arrays, I don't think it's efficient to call it for every sub-array:
const filteredArray = array1.filter(value => array2.includes(value));