Function sample

  • Gets a random element from array.

    NOT support object

    Type Parameters

    • T

    Parameters

    • array: T[]

      The array to sample.

    Returns T

    Returns the random element.

    Since

    5.7.0

    Example

    sample([1, 2, 3, 4])
    // => 2