differenceBy es-toolkit
Transforms elements of two arrays with a conversion function, computes their difference, and returns a new array.
Usage
differenceBy(firstArr, secondArr, mapper)
Use differenceBy when you want to compute the difference between two arrays based on a specific criterion. It compares each element after transforming it with the conversion function, and returns the elements that exist only in the first array.
You can also compute the difference based on string length.
Parameters
The base array to compute the difference from.
The array containing elements to exclude from the first array.
The function that maps elements of both arrays. Elements are compared based on the values returned by this function.
Returns
A new array containing elements that exist only in the first array, based on the transformed values.
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.