4 ms·
While caching the array.length had been important, it probably does little with modern engines. I remember tests from a few years ago, which actually favored th
by masswerk 8y ago
While caching the array.length had been important, it probably does little with modern engines. I remember tests from a few years ago, which actually favored the first variant. (Probably, because engines could more easily identify the local context and optimize on this. Also, in terms of runtime optimization, there's much to win and you'd want to tackle this issue as one of the very first things.)
That said, it's still a good idea, even if it's just for pointing out that the constraint on the loop won't change.