Creates a function that returns a random sample on each call.
Source array; captured by the returned function and not mutated.
Sample size passed to randomSample on each call. Defaults to 1.
1
A zero-argument function that returns a fresh random sample each time it is called.
const items = [1, 2, 3, 4];const sampleTwo = randomSampler(items, 2);sampleTwo(); // random 2-item sample each call Copy
const items = [1, 2, 3, 4];const sampleTwo = randomSampler(items, 2);sampleTwo(); // random 2-item sample each call
Creates a function that returns a random sample on each call.