Closed frankcash closed 8 years ago
I compared optimized and unoptimized loops in Firefox 42.0, and there seems to be no performance difference: https://jsperf.com/for-vs-length
In utter ignorance of any microbenchmark, I tend to use the 'new' .map, forEach, filter etc methods. Most times I ask myself: is there really need to declare and maintain a new counter variable (or even more) in order to write this? As a bonus: map, filter etc are really a bonus on readability.
Sorry this is a year old and I should've closed it I just forgot about it/let it go.
I've since repented and understand that microbenchmarks with any good JIT will not increase performance by an substantial degree, etc.
Optimizes the for loop.
Any part of the loop that is in the second part
for(first;second;third)
will be checked once per loop. It gets costly to access an object property every run through unless necessary.