Type of elements within the outer sequence.
Type of elements within the inner sequence.
Type of key produced by the key selectors.
Type of element returned by resultSelector.
The outer sequence.
Sequence whose elements are joined with the outer sequence.
Selector that extracts the join key from each outer element.
Selector that extracts the join key from each inner element.
Projection that combines an outer element with a matching inner element.
OptionalkeyComparator: EqualityComparator<TKey, TKey>Optional equality comparator used to match keys. Defaults to the library's standard equality comparison when omitted.
A sequence generated by applying resultSelector to each matching pair.
The inner sequence is fully enumerated to build an in-memory lookup before outer elements are processed. The outer sequence is then enumerated lazily and its original ordering is preserved. This is an inner join; unmatched outer or inner elements are not emitted.
const categories = [
{ id: 1, name: 'Fruit' },
{ id: 2, name: 'Vegetable' },
];
const products = [
{ name: 'Apple', categoryId: 1 },
{ name: 'Banana', categoryId: 1 },
{ name: 'Carrot', categoryId: 2 },
];
const joined = join(
categories,
products,
c => c.id,
p => p.categoryId,
(c, p) => ({ category: c.name, product: p.name })
).toArray();
console.log(joined);
// [
// { category: 'Fruit', product: 'Apple' },
// { category: 'Fruit', product: 'Banana' },
// { category: 'Vegetable', product: 'Carrot' }
// ]
Produces a projection from the sequence and a second sequence by matching elements that share an identical join key.