The _.intersection() method in Lodash creates a new array from existing arrays by including only those values that are common in the given arrays.
_.intersection([arrays])
This method accepts the following parameters:
arrays: The arrays to be inspected.This method returns an array in which only the common values of the given arrays are included.
Let’s look at an example of the _.intersection() method in the code snippet below:
In the HTML tab:
lodash script.In the JavaScript tab:
_.intersection() method to find the common values in both arrays.In the output, we see an array in which only the common values of both arrays are included.