in reply to Re: random index in array - no duplicates
in thread random index in array - no duplicates

A splice isn't efficient. It's essentially quadratic in the size of the array, while a shuffle is linear.

Or to be more precise. If you have an array of size N and you want to draw M elements from it (without duplicates), splice will take time proportional to N * M, while the suffle will take time proportional to N + M (or just M if you get a reference to the array).

Abigail