Skip to main content
variable countOccurrences
import { countOccurrences } from "https://deno.land/x/30_seconds_of_typescript@v1.0.1/util.ts";

Counts the occurrences of a value in an array.

Use Array.prototype.reduce() to increment a counter each time you encounter the specific value inside the array.

type

<T = any>(arr: T[], val: T) => unknown