typefinity
    Preparing search index...

    Function randomItem

    • Select a random item from an array

      Type Parameters

      • const T extends readonly unknown[]

      Parameters

      • array: T

        The array to select an item from

      Returns T[number]

      A randomly selected item from the array

    • Select a random item

      Type Parameters

      • const T

      Parameters

      • item1: T

        The first candidate to choose from

      • item2: T

        The second candidate to choose from

      • ...rest: readonly T[]

        The other candidates to choose from

      Returns T

      A randomly selected item from the provided parameters