intersection

Modified on Fri, 18 Aug 2023

Description

Return the new array of intersecting values.

Syntax

intersection(array1, array2, arrayN)

Parameters

Input ParameterTypeDescription
array1Arrayarray to inspect
array2Arrayarray to inspect
arrayN (optional)Arrayarray to inspect

Return value

Type
Array<any>

Sample

ExampleResultDescription
intersection([1, 2, 3], [2, 3, 4])[2, 3]Return common values in 2 arrays
intersection([1, 2, 3], [2, 3, 4], [3, 4, 5])[3]Return common values in 3 arrays
intersection([1, 2], [2, 3], [2, 1], [3, 2])[2]Return common values in 4 arrays

To view all the List functions, click here.

See Also