• Gets n random elements at unique keys from collection up to the size of collection.

    Type Parameters

    • T

    Parameters

    • collection: readonly T[]

      The array from which elements will be sampled.

    • n: number = 1

      The number of elements to sample. default is 1.

    Returns T[]

    An array containing n random elements from the provided collection.