Caching length property vs getting it each time in the loop

save length of the array in the variable vs get it the loop
7 years ago
User agent: Mozilla/5.0 (iPad; CPU OS 10_2_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.79 Mobile/14D27 Safari/602.1
Test name Executions per second
Cache length 2674.9 Ops/sec
Do not cache 1358.9 Ops/sec
Script Preparation code:
Tests:
  • Cache length

  • Do not cache

Open this result on MeasureThat.net