---
title: "@std/collections"
description: "Pure functions for common tasks related to collection types like arrays and objects"
jsr: jsr:@std/collections
pkg: collections
version: 1.1.6
generated: true
stability: stable
---
<!-- Autogenerated from JSR docs. Do not edit directly. -->

## Overview

<p>Pure functions for common tasks around collection types like arrays and
objects.</p>
<p>Inspired by
<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/" rel="nofollow">Kotlin's Collections</a>
package and <a href="https://lodash.com/" rel="nofollow">Lodash</a>.</p>

```js
import { intersect, sample, pick } from "@std/collections";
import { assertEquals, assertArrayIncludes } from "@std/assert";

const lisaInterests = ["Cooking", "Music", "Hiking"];
const kimInterests = ["Music", "Tennis", "Cooking"];

assertEquals(intersect(lisaInterests, kimInterests), ["Cooking", "Music"]);

assertArrayIncludes(lisaInterests, [sample(lisaInterests)]);

const cat = { name: "Lulu", age: 3, breed: "Ragdoll" };

assertEquals(pick(cat, ["name", "breed"]), { name: "Lulu", breed: "Ragdoll"});
```

### Add to your project

```sh
deno add jsr:@std/collections
```

<a href="https://jsr.io/@std/collections/doc" class="docs-cta jsr-cta">See all symbols in @std/collections on
<svg class="inline ml-1" viewBox="0 0 13 7" aria-hidden="true" height="20"><path d="M0,2h2v-2h7v1h4v4h-2v2h-7v-1h-4" fill="#083344"></path><g fill="#f7df1e"><path d="M1,3h1v1h1v-3h1v4h-3"></path><path d="M5,1h3v1h-2v1h2v3h-3v-1h2v-1h-2"></path><path d="M9,2h3v2h-1v-1h-1v3h-1"></path></g></svg></a>

<!-- custom:start -->
<!-- Add persistent custom content below. This section is preserved across generations. -->

<!-- custom:end -->
