Function sample
- sample<T>(array, options?): T | undefined
ExperimentalType Parameters
Parameters
- array: ArrayLike<T>
The array to sample from.
Optionaloptions: SampleOptionsOptions modifying the sampling behavior.
Returns T | undefined
A random element from the given array, or
undefinedif the array is empty.- array: ArrayLike<T>
Returns a random element from the given array.
UNSTABLE: New API, yet to be vetted.