@sensimods/utility-lab
    Preparing search index...

    Function sample

    • Returns a random element from an array.

      Type Parameters

      • T

      Parameters

      • arr: T[]

        The array to sample from.

      Returns T | undefined

      A single random element from the array, or undefined if the array is empty.

      sample(['apple', 'banana', 'cherry']) // e.g., 'banana'