Feature request: Array.prototype.random
w.white9 at icloud.com
Thu Jun 15 22:20:08 UTC 2017
And prng.pick(str), prng.pick(set) etc.?
> On 15 Jun 2017, at 22:34, Michał Wadas <michalwadas at gmail.com> wrote:
> I believe it's too specialized to be a part of Array interface.
> Though, I think JS should have better support for randomness, so we could do:
> prng.sample(arr, 5);
> prng.sampleWithoutRepetitions(arr, 4);
> On 15 Jun 2017 20:42, "Will White" <w.white9 at icloud.com> wrote:
> Dear es-discuss,
> I would like to propose Array.prototype.random, which would return a random array element the same way `array[Math.floor(Math.random() * array.length)]` does, because every time I want a random array element, I have to remember how to do it. Do you think this is a useful addition to the language?
> Will White
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss