VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-intersection-method/

⇱ Lodash _.Intersection() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.Intersection() Method

Last Updated : 2 Sep, 2024

Lodash _.intersection() method is used to take the intersection of one or more arrays. It is the same as the intersection in set theory.

Syntax:

_.intersection([arrays]);

Parameters:

  • It takes an array as a parameter.

Return Value:

  • It returns the array after the intersection of arrays.

Example 1: In this example, we are finding the intersection of two arrays.

Output:

👁 Image

Example 2: In this example, we are finding the intersection of more than two arrays.

Output:

👁 Image

Example 3:In this example, we are finding the intersection of two arrays in which one is empty that is why we did not get any new intersected array as they do not have common elements.

Output:

👁 Image
Comment