Function take

  • Destructively remove and return a random element from an array.

    See pick() for a non-destructive version of this function.

    Type Parameters

    • T

    Parameters

    • array: T[]

      Take a random element from here, destructively.

    Returns T

    The element that was removed.

    An error if the array is empty.