Returns all distinct elements in the given array, preserving order by first occurrence.
Uniqueness is determined by same-value-zero equality.
The type of the elements in the input array.
The array to filter for distinct elements.
An array of distinct elements in the input array.
import { distinct } from "@std/collections/distinct";import { assertEquals } from "@std/assert";const numbers = [3, 2, 5, 2, 5];const distinctNumbers = distinct(numbers);assertEquals(distinctNumbers, [3, 2, 5]); Copy
import { distinct } from "@std/collections/distinct";import { assertEquals } from "@std/assert";const numbers = [3, 2, 5, 2, 5];const distinctNumbers = distinct(numbers);assertEquals(distinctNumbers, [3, 2, 5]);
Returns all distinct elements in the given array, preserving order by first occurrence.
Uniqueness is determined by same-value-zero equality.