Skip to main content
Module

std/collections/mod.ts>distinct

Deno standard library
Go to Latest
function distinct
import { distinct } from "https://deno.land/std@0.102.0/collections/mod.ts";

Returns all distinct elements in the given array, preserving order by first occurence

Example:

const numbers = [ 3, 2, 5, 2, 5 ]
const distinctNumbers = distinct(numbers)

console.assert(distinctNumbers === [ 3, 2, 5 ])

Parameters

array: Array<T>

Returns

Array<T>