I have a large array of integers, and want to set many sequential values to zero at once. What's the fastest way to do this?
My current solution does not appear very elegant or fast:
const data = getLargeArray();
const startAt = 1750;
const numItems = 4500;
for (let i = 0; i < numItems; i++) {
data[startAt + i] = 0;
}
Is there a faster way that works without a loop?