I have a massive collection of items — approximately 30000 in total.
startIndex = Math.floor( Math.random() * arr.length )
I am interested in selecting a random subset from the entire collection.
My goal is to iterate through the array starting at startIndex
and ending at startIndex + n
.
Important note: It is crucial for this array to remain unchanged, as it would be too resource-intensive to re-render the entire dataset.
What approach would be most effective for this task? Should I use a for
loop or a while
loop?