ArrayUtil - intersect(Array a, Array b)

Finds the elements present in all arrays.

Any number of arrays can be provided as parameters.

Table 1. Parameters
Name Type Description
a Array An array
b Array An array
Table 2. Returns
Type Description
Array An array of elements from array a that were found in all of the other input arrays. Duplicates are removed.

var arrayUtil = new ArrayUtil();
var a1 = new Array("a", "b", "c");
var a2 = new Array("c", "d", "e");
gs.print(arrayUtil.intersect(a1, a2));

Output: c