4 ms·
You call "strong claim" something I prefixed with "probably"? It seems for loops in your link can be slower because .length (a function in disguise) is repeate
by jraph 2y ago
You call "strong claim" something I prefixed with "probably"?
It seems for loops in your link can be slower because .length (a function in disguise) is repeatedly called. I do save .length when writing JS. .length calls has been hard to optimize and it can't hurt too much to cache it at the start of the loop.
Now it's good news if today's engines are able to optimize most of .forEach. The amount of optimization JS engines can do never ceases to amaze me and yes, any performance claim in JS needs to be constantly reviewed and checked at the time it is discussed.
You can't take a "probably" as gospel. Still, it was a bit lazy of me to not re-check, I guess being called out was warranted.