Caching length property vs getting it each time in the loop
save length of the array in the variable vs get it the loop
8 years ago
User agent:
Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/52.0.2743.84 Mobile/13G36 Safari/601.1.46
Test name |
Executions per second |
Cache length |
6438.7 Ops/sec |
Do not cache |
3237.4 Ops/sec |
Tests:
-
Cache length
-
Do not cache
Open this result on MeasureThat.net