'Find the element common in all the arrays

I have multiple arrays and I have to find the element common in all the arrays. For example, I am having 5 arrays as follows:

var array1 = ['A', 'B', 'C', 'D', 'E'];
var array2 = ['B', 'C', 'E'];
var array3 = ['B', 'C', 'Z'];
var array4 = ['C'];
var array5 = ['A','C'];

I have to get the C as the output as it is the only element common in all the 5 arrays.

output = ['C'] ;

Is it possible to achieve this in typescript? Can anyone help me out here.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source