Type of elements within the source iterable.
Type of key produced by keySelector.
The source iterable.
Iterable whose elements define the keys considered part of the intersection.
Selector used to project each element to the key used for comparison.
OptionalkeyComparator: EqualityComparator<TKey, TKey> | OrderComparator<TKey, TKey>Optional comparator used to compare keys. Both equality and order comparators are supported; defaults to the library's standard equality comparison when omitted.
A sequence containing the intersection of the two sequences based on matching keys.
other is fully enumerated to materialise the inclusion keys before yielding results. Source ordering is preserved.
const products1 = [
{ name: 'Apple', category: 'Fruit' },
{ name: 'Carrot', category: 'Vegetable' },
];
const products2 = [
{ name: 'Banana', category: 'Fruit' },
{ name: 'Broccoli', category: 'Vegetable' },
];
const result = intersectBy(products1, products2, p => p.category).toArray();
console.log(result);
// [
// { name: 'Apple', category: 'Fruit' },
// { name: 'Carrot', category: 'Vegetable' }
// ]
Returns the elements whose keys are common to source and other.