intersectionWith es-toolkit
Returns a new array containing the intersection of two arrays based on a custom comparison function.
Usage
intersectionWith(firstArr, secondArr, areItemsEqual)
Use intersectionWith when you want to find common elements in two arrays using a user-defined comparison function. This is useful for complex objects that are difficult to handle with simple value comparisons or when special comparison logic is needed.
Complex comparison logic can also be implemented.
Parameters
The first array to compare.
The second array to compare.
A function to determine if two elements are equal. Should return true if equal, false otherwise.
Returns
Returns a new array containing elements commonly included in both arrays based on the custom comparison function. The result consists of elements from the first array.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.