intersectionBy es-toolkit
Returns a new array containing the intersection of two arrays based on the result of a transformation function.
Usage
intersectionBy(firstArr, secondArr, mapper)
Use intersectionBy when you want to find common elements in two arrays based on a specific attribute or transformed value. It compares the results of processing each element with a transformation function to find the intersection. This is useful when comparing by a specific property in object arrays or when complex transformation logic is needed.
Complex transformation logic can also be applied.
Parameters
The first array to compare.
The second array to compare.
A function that transforms each element to create comparison criteria.
Returns
Returns a new array containing elements commonly included in both arrays based on the result of the transformation 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.