3 ms·
Caching the length property appears to have only a small impact on performance across Chrome, Firefox and Safari (caching is faster in Firefox, slower in Chrome
by ryanpetrich 8y ago
Caching the length property appears to have only a small impact on performance across Chrome, Firefox and Safari (caching is faster in Firefox, slower in Chrome, and about the same in Safari). Perhaps it's better to recommend the non-cached loop iteration instead?
The quick microbenchmark I checked this on: https://jsperf.com/for-to-length/1 https://jsperf.com/for-to-length/1