Skip to main content
Go to Latest
function minWith
import { minWith } from "";

Returns the first element having the smallest value according to the provided comparator or undefined if there are no elements


import { minWith } from "";
import { assertEquals } from "";

const people = ["Kim", "Anna", "John"];
const smallestName = minWith(people, (a, b) => a.length - b.length);

assertEquals(smallestName, "Kim");


array: readonly T[]
comparator: (a: T, b: T) => number


T | undefined