Skip to content

Function: intersect() ​

intersect<T>(arr1, arr2): T[]

Defined in: packages/validate-openalex/src/events/getter.ts:31

Return the intersection of two string arrays.

The result contains values from arr1 that are also present in arr2. The order of items in the returned array follows the order in arr1. Comparison is done with strict equality (case-sensitive).

This function is non-mutating: input arrays are not modified.

Type Parameters ​

T ​

T

Parameters ​

arr1 ​

T[]

The array whose elements are filtered by membership in arr2.

arr2 ​

T[]

The array used to test membership of arr1's elements.

Returns ​

T[]

A new array containing the elements present in both arr1 and arr2.

Example ​

ts
// returns ['b', 'c']
intersect(['a', 'b', 'c'], ['b', 'c', 'd']);