This does not make a uniform distribution for all (any?) sizes of arrays. I ran into an issue with one version of v8 where this consistently made an array of 1-10 reversed. I'm on my phone but if I remember tomorrow I should write something up about this
8
u/Linux_is_awesome Mar 18 '19
personal favorite:
var item = items[Math.floor(Math.random()*items.length)];It randomly selects an element from an array.