re: How to clear array in javascript VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Genuine question: do you feel like performance is even a concern here? The difference between these operations is probably literally nanoseconds un...

In my opinion, yes.

Performance should always be a concern. Sure, in a single example like this, it seems petty to harp on that one has to use the fastest code ever. But remember that code will almost always be a series of statements.

Consider if the code was littered with the least efficient versions of operations. Methods would take longer to complete, and thus the application would appear slow. And isn't the ultimate goal of software to help humans do things faster (as fast as possible)? :-)

I agree that all things being equal performance should be important. Things are rarely equal though, and in this case I was making a point that I feel that readability matters much more in this situation.

Put another way: people are definitely going to have to read your array clearing code if you write it, so readability is going to be a concern. How many of these array clearing operations do you think it would take to make a noticeable difference in your app's performance? I feel like it would have to be millions.

I come from the generation where every byte counted and I know that optimisation sometimes seems like a lost art, but having something that you can understand without having to scratch your head for a second is more important in almost every situation.

code of conduct - report abuse