Setting an array=0


#1

I need to set every element of an array to 0, not empty, but the value zero. Is there a faster way of doing this than looping through each element individually?


#2

How big is the array? How often does it need to be reset?


#3

Only 25 so not the end of the world just I’m always looking for the most efficient way of doing things. ie utilizing one loop for many tasks instead of multiple loops


#4

JavaScript is so fast that it really doesn’t matter. Even slow devices will be able to set a million array elements to zero in around a second.

In this case, worry more about making the code easy to read and maintain.