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.

    5.7.0

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