I've found lots of questions regarding eliminating duplicates from arrays but I'm trying to identify them. Say I have a multi-dimensional array like
array = [[1,2,3,4],[3,4,5,6],[7,8,3,4]]
I want to return only the values that exist in all the arrays. Thus,
result = [3,4]
I know how to do it with only two arrays
array[0].filter(value => -1 !== array[1].indexOf(value)
However I need to do a similar thing with an n-number of arrays
flatand then filter:const all_duplicates = array.flat().filter((item, index, arr) => arr.indexOf(item) !== index). Then just usenew Setto bring up repeated unique values:const duplicates = [...new Set(all_duplicates)]