Method Array.intersect
Get the intersection of n arrays
-
Syntax
Array Array.intersect([ Array a0 ... an ])
Computes the intersection between the calling array and any number of arrays passed as arguments. Duplicate values are removed from the result. -
Parameters
Array a0 ... an(Optional)- The arrays to intersect with.
- Return value A new array holding the intersection of elements
-
Examples
- To find the intersection of the arrays (0,2,4,1,8,2), (1,3,5,2,9) and (100,2,9,1)
// Define array 1 var a1 = [0,2,4,1,8]; // Define array 2 var a2 = [1,3,5,2,9]; // Define array 3 var a3 = [100,2,9,1]; // Output is Array(2,1) a1.intersect(a2,a3);
-
Download
Source
Unless otherwise noted all code in the JSLab Standard Library is licensed as GPLv3. See http://www.gnu.org/licenses/gpl.html for the entire license.
This function has dependencies and will not work stand-alone. Use the download button above instead of copy/paste.
