To use the intersection function from the underscore library, first install the library using npm:
23 chars2 lines
Then require the underscore module in your javascript file:
index.tsx33 chars2 lines
The intersection function takes in two or more arrays and returns a new array containing the unique values that are present in all of the input arrays. Here is an example usage:
index.tsx190 chars8 lines
In this example, the intersection function is called with three arrays as input (array1, array2, and array3). The output is a new array containing the intersection of these arrays, which is [4].
gistlibby LogSnag