# intersection

Source: https://taxilang.org/docs/language/stdlib/intersection

**Full name:** `taxi.stdlib.intersection`

## Signature

```taxi
declare extension function <T> intersection(collectionA: T[], collectionB: T[]):T[]
```

## Description

Returns a new collection containing only the elements that are present in both of the provided collections.

This function identifies common elements between two collections.

```taxi
// Find common tags between two products
find { productA: Product, productB: Product } as {
   commonTags: intersection(productA.tags, productB.tags)
}
```

## Examples

Returns only elements present in both collections, identified by value equality.

Schema:

```taxi
type Tag inherits String
model Product {
   name: ProductName inherits String
   tags: Tag[]
}
```

Query:

```taxi
given {
   productA: Product = {
      name: 'Smartphone',
      tags: ['electronics', 'mobile', 'camera', 'touchscreen']
   },
   productB: Product = {
      name: 'Digital Camera',
      tags: ['electronics', 'camera', 'photography', 'zoom']
   }
}
find {
   productAName: productA.name
   productBName: productB.name
   commonTags: intersection(productA.tags, productB.tags)
}
```

Result:

```json
{
  "productAName": "Smartphone",
  "productBName": "Digital Camera",
  "commonTags": [
    "electronics",
    "camera"
  ]
}
```
