Note: Not a duplicate problem.. here I need to skip empty arrays.
Say I have several arrays like:
var a = [1, 2, 3, 4],
b = [2, 4],
c = [],
d = [4];
Using following function, I could get the desired result: [4]
var a = [1, 2, 3, 4],
  b = [2, 4],
  c = [],
  d = [4];
var res = [a, b, c, d].reduce((previous, current) =>
  !previous.length || previous.filter((x) => !current.length || current.includes(x)),
);
console.log(res)I included !current.length || above to bypass empty array c. But this doesn't work if first array in the collection i.e. a is empty. The result would be [].
 
     
    