clean-jsdoc-theme TypeDoc APIv0.0.0

sampleSize

sampleSize<T>(array: T[], count: number): T[]

Source: array.ts:266

Picks multiple random elements from an array

Type Parameters

  • T — Array element type

Parameters

  • array (T[]) — The input array
  • count (number) — Number of elements to pick

Returns

  • T[] — Array of random elements

Example

CODE
sampleSize([1, 2, 3, 4, 5], 3) // [2, 4, 1] (random)